Yes u can with
friend.object.name

On Apr 11, 10:13 pm, John Grimes <[email protected]> wrote:
> Hi all,
>
> Say I had the following form:
>
> <% form_for @user do |f| %>
>   <%= f.error_messages %>
>   <% f.fields_for :friends do |friends| %>
>     <%= friends.text_field :relationship_to_you %>
>   <% end %>
>   <p><%= f.submit "Submit" %></p>
> <% end %>
>
> Is it possible to access the current object within that fields_for
> block as it iterates through?
>
> For example, could I add another line that looked something like this
> with the friend's name:
>
> <% form_for @user do |f| %>
>   <%= f.error_messages %>
>   <% f.fields_for :friends do |friends| %>
>     <label><%= friend.name %></label>
>     <%= friends.text_field :relationship_to_you %>
>   <% end %>
>   <p><%= f.submit "Submit" %></p>
> <% end %>
>
> Thanks for your help.
>
> John Grimes

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to