开发者

Rails custom submit_tag

Is there a way to control the *submit_tag* in the form to invoke different action to the default 'update' action?

I tried to use the submit_tag below, 开发者_如何学编程but it still redirect me to 'update' action in people controller.

<%= submit_tag "Save", :controller => "people", :action => "set_password", :method => "put" %>

The reason why I'm doing this is that, I have two update forms for the Person class, one for updating the basic information, and one for updating the password. I would like to handle the form submit differently. For 'updating password form', i have to something additional. * validate the additional user input (current password) * direct to 'update password' form if there is an error

Am I doing the wrong thing? Or I should distinguish the cases inside the 'update' method?


You have to tell the form where to go, not on the submit_tag:

<%= form_tag @object, url, :method => 'PUT' %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜