Reputation: 5603
I have the following in my view:
<%= form_for :search do |f| %>
<%= f.label :search %>
<%= f.text_field :search %>
<%= f.submit 'Search' %>
<% end %>
I am attempting to create a post
action from the f.submit
button which will route to a specific controller action. I then need that action to redirect back to my initial view, but pass in the text_field
parameter on the redirect. How can I access the text_field
parameter in my view as well as pass it through a redirect?
Upvotes: 0
Views: 1567
Reputation: 7921
The easiest way to do it is from this question: Passing parameters in rails redirect_to
redirect_to search_path({ :search => params[:search] })
Upvotes: 1
Reputation: 1392
your parameters will come in a normal hash, and you can access them via params[:search][:search]
in your controller.
generally just look into the rails server log, you can see the data your browser sends to rails right there
Upvotes: 1