I struggled with this alone for several days and cannot figure out what happened. I am trying to allow attachments of polymorphic files of the Item
model, which belongs to the Location
model. My routes are defined as:
resources :locations do resources :items post :sort end resources :items do resources :assets
I followed the tutorial on how to do this using carrier and nested_form . However, after setting everything up, I get the following error when requesting the New
action for the Item
model: wrong number of arguments (4 for 3)
. He tells me that an error occurs on line 7 of this view:
<%= nested_form_for [@location, @item], :html => { :multipart => true } do |f| %> <p> <%= f.label :name %><br /> <%= f.text_field :name %> </p> <%= f.fields_for :assets do |a_form| %> ### LINE 7 #### <p> <%= a_form.label :file %><br /> <%= a_form.file_field :file %> <%= a_form.hidden_field :file_cache %> </p> <%= a_form.link_to_remove "Remove this attachment" %> <% end %> <%= f.link_to_add "Add attachment", :assets %> <p><%= f.submit %></p> <% end %>
If I do not use the nested_form stone and start the view with the usual form_for
, I get no errors and can successfully attach one file to Item
. I can try and continue without a gem, but (as I understand it) nested_form will automate some functions, such as deleting files and creating ajax to add new attachments.
I am just wondering if anyone has encountered this error or know what error I am making that causes problems with nested_form? I understand what the error means, just not sure where / why the extra argument is being added. I really appreciate any understanding you can provide!
FYI my dev setup: rails (3.1.0, 3.0.10), nested_form (0.1.1), carrier wave (0.5.7)
Denny source share