Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两个提交按钮,它们都在我的控制器中使用相同的创建操作。如何使用表单发送信息(无需用户输入)?
例子:
按钮 1:使用 1 创建一个数据库条目。
按钮 2:使用 2 创建一个数据库条目。
您可以使用这样的隐藏字段:
<%= 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' %>