vendredi 22 janvier 2016

Referencing multiple models in Rails

I have departments with many positions with many crewmembers. I am trying to make a page of a master list of crewmembers, grouped by their positions which are grouped by their departments. I know the code below is wrong, but hopefully someone could point me in the correct direction.

<% @departments.each do |dept| %>
    <% if Department.position.include? crewmember %>
      <%= dept.department %><br />
      <% @positions.each do |pos| %>
        <% if Position.crewmember.any? %>
          <%= pos.position %><br />
          <%= pos.position.crewmember %>
        <% end %>
      <% end %>
    <% end %>
  <% end %>

Aucun commentaire:

Enregistrer un commentaire