Tak buduję formę w Rails 3.1, wykorzystująceszyny simple_nested_form_for fields_for niewłaściwą liczbę argumentów
<%= simple_nested_form_for(@person, :url => collection_url, :html=>{:multipart => true}) do |f| %>
<%= render :partial => "form", :locals => { :f => f } %>
<% end %>
ale ten wiersz w częściowym jest przyczyną problemu:
<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 %>
Więc tutaj jest model:
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
Kontroler używa dziedziczonego zasobu zasobów.
Co jest nie tak? Dzięki za pomoc.
co to za błąd? – apneadiving
zła liczba argumentów (4 za 3), zobacz drugi fragment kodu :) – randomor