Ruby on Rails Monday, January 31, 2011

Here's a gem based on an earlier plugin for this sort of thing:

https://github.com/kete/http_url_validation_improved

It's not without issues though. The big one is that URLs these days
can have unicode in them and the URI library (at least in Ruby 1.8.7)
treats them as invalid. Feel free to fork and improve.

Cheers,
Walter

On Mon, Jan 31, 2011 at 11:10 PM, agathe begault
<agathe.begault@gmail.com> wrote:
> Hello everybody,
>
> I'm trying to link some files from some servers like Sharepoint to my
> application.
>
> my problem is when the link is not good, I'm redirected in a 404 error
> page (which is normal :p).
>
> I would like to know how to something like a validation method to
> display the button to download if the link is correct and to display a
> red button if it's not.
>
> I tried some different things like :
>
> def remote_file_exist?(url)
>  res = Net::HTTP.get_response(URI.parse(url)) rescue SocketError
>  res
> end
>
>
> Without success. Each time some files were considered as unvalide
> while they were valid and vice versa.
>
> It maybe comes from my code, that's why i continue to try other
> possibilities.
>
> Any idea or suggestion ?
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment