Reputation: 1528
I'm starting to develop a small application in Ruby On Rails. I have a short form in a view:
<%= form_for @event do |f| %>
<%= f.fields_for :items do |item| %>
<input type="number" id="quantity" />
<% end %>
<%= f.submit 'Join', :name => "join" %>
I want to after click 'submit', run a controller's method that access to the data included in each of the fields in the form and perform insertions on the database.
Actually the controller's method called is "update" but I want to call other controller's method cause update is only for the event creator so other users can't submit the form.
How do I customize the action of the submit button to run controller's function (not update)?
Upvotes: 4
Views: 6530
Reputation: 16730
<%= form_for @event, :url => { :action => "custom_update" } do |f| %>
You may want also to specify the method
<%= form_for @event, :url => { :action => "custom_update" }, :html => { :method => "put" } do |f| %>
Upvotes: 5