I want to construct a url within my rails app that points to another server that isn't running rails. Using url_for
almost satisfies my requirements, but it requires a controller key which I don't need (redirecting to a top level page on the external site).
The reason I want to do this is so that I have a cleanly construct a url with a hash of arguments (some of which are determined at runtime).
You can call to_query
on Hash in rails which will take care of url encoding etc. So maybe something like this:
params = {
:a => "http://google.com",
:b => 123
}
url = "http://example.com?#{params.to_query}"
What do you think about URI::HTTP?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With