In my last Rails project I had to overwrite default_url_options
in application_controller.rb
to always pass a param through every request, like this:
def default_url_options
{ :my_default_param => my_param_value }
end
Now every url helper attaches a my_default_param at the end of every generated url.
For instance user_url(@current_user)
generates a url like:
http://www.example.com/users/1?&my_default_param=my_param_value
But sometimes I need to generate the url without my_default_param. Is there some option I can pass to the url helper so that user_url(@current_user, some_option: some_option_value
) will return only:
http://www.example.com/users/1?&my_default_param=my_param_value
?
PN: I already tried with :overwrite_params=> { }
but it doesn't work, probably because it's evaluated before default_url_options.
And if not, is there another way to obtain the @current_user url without the my_default_param attached?
Thank you.