Say I have an Article model, and in the Article model 'settings' view I have two submit buttons outside of a form, "update Details" and "Next Template".
My question is how can I know which button is clicked in the controller. Both submit button is outside of a simple form. I tried like:
<%= f.submit "update Details",name: "update_details", class: "x-update" %>
<%= f.submit 'Next Template', name: "next_template", class: "x-next" %>
and the logic is the same on the controller
if params[:update_details]
[..]
elsif params[:next_template]
[..]
end
but it doesn't work. How do I do that? I can't change the route, so is there a way to send a different variable that gets picked up by [:params]?
Aucun commentaire:
Enregistrer un commentaire