mattC
mattC

Reputation: 373

Rails - passing multiple params to a form_tag

I have a form_tag that I'm using for a search. I need to pass not only the :term (what is being searched for), but also the :ques_num parameter. Currently, :ques_num is not being passed in.

<%= form_tag display_questions_path(:ques_num => 2), method: :get do %>
  <%= text_field_tag :term, params[:term], placeholder: "Search Terms..." %>
<% end %>

This directs me to the address with the :term passed in, but not :ques_num. How would I go about doing this?

Upvotes: 0

Views: 247

Answers (1)

kasperite
kasperite

Reputation: 2478

You should use hidden_field_tag instead:

<%= form_tag display_questions_path, method: :get do %>
  <%= text_field_tag :term, params[:term], placeholder: "Search Terms..." %>
  <%= hidden_field_tag :ques_num, 2 %>
<% end %>

Upvotes: 1

Related Questions