In my main template I have the following:
<%= render :partial => "delivery_date", :collection => @brand.delivery_dates, :locals => {:form => f} %>
However when the partial tries to use the form local variable, I get this error
Showing app/views/brands/_delivery_date.html.erb where line #2 raised:
wrong number of arguments (0 for 1)
Extracted source (around line #2):
1: <%= delivery_date.id %>
2: <%= form.text_field :name %>
3: <% new_or_existing = delivery_date.new_record? ? 'new' : 'existing' %>
4: <% prefix = "brand[#{new_or_existing}_delivery_date_attributes][]" %>
5: <% fields_for prefix, delivery_date do |dd_f| %>
Does anyone understand what this error means?
Actually I want to do
<% form.fields_for delivery_date do |dd_f| %>
but that fails as well.
I tried replacing :locals with :locals => { :f => f } and referring to the form using f in the partial. No effect, the error then is undefined method or variable f.
...
Ok rather than asking you to debug an error, the question is also how to render fields_for in a nested partial form:
In main template:
<% form_for @object do |f| %>
<% render :partial => 'child', :collection: @object.child %>
<% end %>
In child template:
<% form.fields_for child do |c_f| %>
<%= c_f.text_field :foo %>
<% end %>
What is the appropriate way to pass this form object?
Sorry forgot to add environment:
Ruby 1.8.7
Rails 2.3.? (have to look up minor version, don't have the code in front of me)
(I know this is a newbie question :( )