Reputation: 124
I want to update a model record without using the default update method. I want to use my custom method to update it. I want to use custom method like
def update_record do
end
The problem is whenever I retrieve a record, it automatically calls update method, instead of my custom method as shown below:
<%= form_for([@promotion], url: {action: :update_record}) do |f| %>
<% end %>
I have added rout.
resources :promotions do
collection {
post :update_record
}
end
Thanks in advance.
Upvotes: 0
Views: 98
Reputation: 7948
You should change the method from POST to patch:
resources :promotions do
collection {
patch :update_record
}
end
Upvotes: 1