ruby on rails 3 - redirect_to external url passing params -


i need pass params in redirect_to method external url...

i know can redirect:

redirect_to my_url_path(param1: "foo", param2: "bar") 

but want external url. example:

redirect_to "www.example.externaldomain.com/process/xightdjtrideor", param1: "foo", param2: "bar" 

you can use ruby uri module , create own helper:

def generate_url(url, params = {})   uri = uri(url)   uri.query = params.to_query   uri.to_s end 

then url:

redirect_to generate_url("www.example.externaldomain.com/process/xightdjtrideor", :param1 => "foo", :param2 => "bar") 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -