Reputation: 1062
On the index.html.erb
page I have a form_for like this :
<%= form_for @cv do |f| %>
<%= f.submit "Verrouiller", :class => 'btn btn-primary btn-xs'%>
<% end %>
Do you know how I can launch a method defined in the controller when I click on submit?
the method in my controller is define like :
def verrou
#the script here
end
Upvotes: 0
Views: 41
Reputation:
This is called Resource-oriented style
, here is an example from the Rails API:
<%= form_for(@cv, url: verrou_path) do |f| %>
...
<% end %>
And as expected, you need to define your route to verrou
on your routes.rb
Upvotes: 2