I am trying to pass a parameter params[:tab] => "drive"
in car_path method using form_tag but it doesnt gets available in car_path params. Here is what i am trying
<%=
form_tag(
car_path(@user.id),
{
:method => :get,
params[:tab] => "drive",
:class => "form form-horizontal"
}
) do
%>
Use this:
<%= form_tag(car_path(@user.id, :tab => "drive"), {:method => :get, :class => "form form-horizontal"}) do %>
Pass it with the car_path
as a query parameter.
UPDATE
Look at action="/visitors/198454?tab=drive"
, tab = drive
is passed in params. Access it as params[:tab] in your controller.
A little different idea: isn't it better to use a hidden field inside the form?
<%= hidden_field_tag :tab , "drive" %>
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