开发者

Popup with edit action not working in rails 3

I have popup which is opened using:

<%= link_to user.username, "/users/"+user.id.to_s+"/edit", :method => :post, :target=> "_blank" %>

edit.html.erb file is:

<div id="dvUserMgmt" class="popup">
<%= form_for(:user, :url => { :controller => 'users', :action => 'update'}) do |f| %>
<table>
 <tr>
   <td class="labelfield">*Name</td>
   <td class="textfield">
    <input type="text" name="tb_realname" value=<%= @realname %> />
   </td>
 </tr>
 <tr>
   <td class="buttons" colspan="3">开发者_如何学Go;             
    <%= submit_tag 'Update', :url => { :controller => 'users', :action => 'update'}, :class => 'popup_closebox' %>
    <%= tag :input, :type => 'button', :value => 'Cancel', :class => 'popup_closebox' %>
   </td>
 </tr>
</table>
<% end %>
</div>

Upon clicking update button, the action update is not getting executed. Can anyone point where is the issue?


Lots of code is not written the Rails way, let's correct it and see if it changes your result.

1) correct your line, but explain wh you have a post method for an edit?

<%= link_to user.username, edit_user_path(user), :method => :post, :target=> "_blank" %>

2) Rails knows your entry already exists, I guess @user is defined

<%= form_for @user do |f| %>

3) use the form helpers:

<%= f.submit 'Update', :class => 'popup_closebox' %>

4) Provide your params to help debugging.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜