How do I send information with a form_for form?
I have two submit buttons both using the same create action in my controller. How can I send information with a form (without the user inputting it)?
Example:
Button 1: Creates a database entry with 1.
B开发者_如何学Cutton 2: Creates a database entry with 2.
You can use a hidden field like this:
<%= form_for @model do |f| %>
<%= f.hidden_field :entry, 1 %>
<%= f.submit 'Button 1' %>
<%= form_for @model do |f| %>
<%= f.hidden_field :entry, 2 %>
<%= f.submit 'Button 2' %>
精彩评论