I have a one to many relationship between a restaurant and menus. In my
view I want to iterate through each of the menu's belonging to a given
restaurant. I also need to distinguish between the first one in the list
and the rest of them.
What is the best control structure/ method for accomplishing this?
Assume I have @restaurant.menus to get the list
I have a one to many relationship between a restaurant and menus. In my
view I want to iterate through each of the menu's belonging to a given
restaurant. I also need to distinguish between the first one in the list
and the rest of them.
What is the best control structure/ method for accomplishing this?
Assume I have @restaurant.menus to get the list
thanks,
steve
feels like a case of
<% @restaurant.menus.each_with_index |menu, index| %>
* do stuff for all the menus - call a partial probably *
<% if index == 0 %>
* do special stuff for the first one *
<% else %>
* for stuff for the others *
<% end %>
<% end %>