8

所以我在rails 3.1中构建一个表单,使用

<%= simple_nested_form_for(@person, :url => collection_url, :html=>{:multipart => true}) do |f| %>
  <%= render :partial => "form", :locals => { :f => f } %>
<% end %>

但是部分中的这条线导致了问题:

<h2>Badges</h2> 
<ul id="certifications">
// this following line is raising the error "wrong number of arguments (4 for 3)"
<%= f.fields_for :certifications do |certification_form| %> 
    <%= render :partial => 'certification', :locals => { :f => certification_form } %>
<% end %>
</ul>
<%= f.link_to_add "Add a Badge", :certifications %>

所以这里是模型:

class Person < ActiveRecord::Base
  has_many :certifications, :dependent=>:destroy, :order=>:position
  has_many :certificates, :through=>:certifications
  accepts_nested_attributes_for :certifications, :allow_destroy => true
end

控制器正在使用继承的资源 gem。

怎么了?谢谢您的帮助。

4

3 回答 3

11

imorsi 是正确的,我是这样做的:

gem "nested_form", :git => 'git://github.com/ryanb/nested_form.git'

我还删除并重新捆绑了 gem,但我怀疑这没有必要。安装 gem 后不要忘记重新启动服务器。

于 2011-07-19T17:44:12.073 回答
7

在我意识到 gem 与 git 上的版本已过期之前,我遇到了同样的问题。我只是用 git 上的那些手动更新了 gem 文件并修复了问题!

于 2011-07-14T06:37:38.313 回答
-1

我试过了,但没有用

所以我最终做了“捆绑打开nested_form”并从github复制粘贴

于 2011-10-27T22:10:22.607 回答