Reputation: 2240
I have a basic search form in my rails app that records each search that has been entered. I also want my users to be able to initiate a search with a url in the browser. E.g. http://www.example.com/searches?q=foo
I've played around with the different routing options and the logic in my controller but I can't seem to get this form:
<%= form_for(@search) do |f| %>
<div class="field">
<%= f.label :search %><br />
<%= f.text_field :search %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
To initiate a POST action on the database and submit a new search.
Thanks :)
Upvotes: 2
Views: 415
Reputation: 3887
Change your form to do a GET request instead of a POST then you can use both the form and the url:
<%= form_for(@search), :method => :get do |f| %>
Upvotes: 2