ruby-on-rails – rails simple_nested_form_for fields_for错误的参数数量

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – rails simple_nested_form_for fields_for错误的参数数量前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我正在使用rails 3.1构建一个表单
  1. <%= simple_nested_form_for(@person,:url => collection_url,:html=>{:multipart => true}) do |f| %>
  2. <%= render :partial => "form",:locals => { :f => f } %>
  3. <% end %>

但部分中的这一行导致了问题:

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

所以这是模型:

  1. class Person < ActiveRecord::Base
  2. has_many :certifications,:dependent=>:destroy,:order=>:position
  3. has_many :certificates,:through=>:certifications
  4. accepts_nested_attributes_for :certifications,:allow_destroy => true
  5. end

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

怎么了?谢谢您的帮助.

解决方法

我遇到了同样的问题,直到我意识到gem与git上的版本已经过时了.我只是手动更新了gem文件和git上的问题并修复了问题!

猜你在找的Ruby相关文章