i have the problem, that i want to pass custom url params to the form_tag method.
i have tried many ways explained at stackoverflow, but no one seems to be correct for rails 3.2.8.
This is my current:
<%= form_tag search_results_path,
:method => "get",
:params => params.merge(:button => "..."),
class: "form-search" do %>
This doesn’t work too:
<%= form_tag search_results_path,
:method => "get",
:params => params.except(:controller, :action).
merge(:button => "..."),
class: "form-search" do %>
But when search_results_path finish loading, params[:button] is not set.
Thanks for your help.
EDIT:
I try to render a form in a view, which has action="/search/params?button=xxx. This should be the initial state for my tabs and every time the page gets reloaded, this url param should be passed too, to provide my current tab.
dude, please explain WHAT you are trying to do, not how.
You don’t pass parameters to a form, that does not make sense .
Explain what is your goal and I may be able to help you.
If you want to pass parameters from url to your controller through the form, you just create a hidden field set its value with params[:param_name]
EDIT==============
You have to use url_for or polymorphic_path to generate url with parameters.
Like:
or