Association data within a fields_for

How do I use association data from within a fields_for?

I’ve got a has many through relationship between users, schools and
schools_users. A user can have multiple schools and a school has
multiple
users. In schools_users there is a user_role field in addition to the
common
user_id and school_id.

In the show view I have:

<% @school.schools_users.each do |user| %>

<%= user.user.first_name %> <%= user.user.last_name %> <%= user.user_role %> <% end %>

but I can’t figure out how to do the same thing from within the
fields_for
on the edit page.

<%= f.fields_for :schools_users do |f| %>

<%= NEED USER NAME HERE %> <%= f.select(:user_role, active_role_options)%> <%= link_to_remove_fields 'Delete', f %> <% end %>

Thanks for any help!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs