views:

53

answers:

1

Is there any difference between:

<%= event_form.fields_for :client, @client do |client| %>

and

<%= fields_for @event, :client, @client do |client| %>

The parent form looks like this:

<% form_for @event do |event_form| %>
+1  A: 

As I read from the docs (http://bit.ly/bMTJ5B), the first version

<%= event_form.fields_for :client, @client do |client| %>

is used in conjunction with accepts_nested_attributes_for :client and the update / create actions consider the event -> client association.

The second example:

<%= fields_for :client, @client do |client| %>

is the more general case when you need to specify additional models in the same form (see 'Generic Examples' section in the link I provided above. I think the correct form though is to leave out the @event param.

cristian
Thank you for the clarification. I should have known that I had *too much* syntax.
Nate Bird