Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 0.70 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Tables with several children
  2. TvShow - has_many Episodes, has_many Games
  3. Episodes - belongs_to TvShow, has_many Games
  4. Games - belongs_to TvShow, belongs_to Episodes.
  5.        
  6. <% @tvshows.each do |tv| %>
  7. <div class="gamebox">
  8. <h3><%= tv.title -%></h3>
  9.     <% tv.episodes.each do |episode| -%>
  10.     <%= episode.title %><br />
  11.     <ul>
  12.         <% episode.tv_show_games.each do |g| %>
  13.         <li><%= g.title %> (<%= g.user.name %>)</li>
  14.         <% end %>
  15.     </ul>
  16.         <% end -%>
  17. </div>
  18. <% end -%>
  19.        
  20. @games = Game.where('episode_id IS NULL')
  21.        
  22. @games = Game.where(:episode_id => nil)
  23.        
  24. @games = Game.where(episode_id: nil)
  25.        
  26. @game = Game.where(:episode_id => nil)
  27.        
  28. @game= Game.find_all_by_episode_id(nil)