
Untitled
By: a guest on
May 6th, 2012 | syntax:
None | size: 0.70 KB | hits: 16 | expires: Never
Tables with several children
TvShow - has_many Episodes, has_many Games
Episodes - belongs_to TvShow, has_many Games
Games - belongs_to TvShow, belongs_to Episodes.
<% @tvshows.each do |tv| %>
<div class="gamebox">
<h3><%= tv.title -%></h3>
<% tv.episodes.each do |episode| -%>
<%= episode.title %><br />
<ul>
<% episode.tv_show_games.each do |g| %>
<li><%= g.title %> (<%= g.user.name %>)</li>
<% end %>
</ul>
<% end -%>
</div>
<% end -%>
@games = Game.where('episode_id IS NULL')
@games = Game.where(:episode_id => nil)
@games = Game.where(episode_id: nil)
@game = Game.where(:episode_id => nil)
@game= Game.find_all_by_episode_id(nil)