简体   繁体   中英

Rails 3 form error - wrong number of arguments (1 for 2)

I am getting an error on my rails 3.2.16 form:

<%= form_for @group_member, :as => :group_member, :url => {:action=>'edit_group_member', :id=>@group, :person_id => @group_member.person_id} do |f| %>
  <%= hidden_field_tag :person, @group_member.person_id %>
  <p><table border="0" cellpadding="3" cellspacing="0">
  <tr>
    <td><%= f.check_box :admin %></td>
    <td><label for="group_member_admin">Group administrator (can modify members and most group properties)</label></td>
  </tr>
  </table>
  </p>
  <p>
    <%= submit_tag "Save" %>
    <%= submit_tag "Cancel" %>
  </p>
<% end %>

Then I get the error:

wrong number of arguments (1 for 2)
Extracted source (around line #7):

4:   <%= hidden_field_tag :person, @group_member.person_id %>
5:   <p><table border="0" cellpadding="3" cellspacing="0">
6:     <tr>
7:       <td><%= f.check_box :admin %></td>
8:       <td><label for="group_member_admin">Group administrator (can modify members and   most group properties)</label></td>
9:     </tr>
10:   </table></p>

Please help me discover what is wrong with this code.

Remove

:as => :group_member

from form_for .

Sorry, I later realized that this issue was caused by custom code in a plugin that was overriding the helper methods. So, usually this code will work fine.

Certainly something for others to keep in mind if they are frantically trying to debug similar problems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM