I need to redirect to some 3rd party websites. The issue is that some of the urls works to redirect and some doesn’t work, using redirect_to url
With this URL I just do: redirect_to url
When using: redirect_to url
I get ERROR URI::InvalidURIError: bad URI(is not URI?)
So, I tried to just do:
redirect_to URI.encode(url)
… and it works! But then the URL in example 1 is not working anymore. Says the site is not found. No error in Rails though.
So, I need an approach that works with both (all?) URIs. Any ideas?
Using Ruby 1.9.3 and Rails 3.2.5
Solved it like this:
Works for my app so far.