Hi All, I''m pretty new to ROR. I got 3 tables: Team, with columns name, world_ranking, star_player and img_url Result with columns round, score and team_name Player with columns first_name, last_name, position and player_number my models relationships look like this class Team < ActiveRecord::Base attr_accessible :image_url, :name, :star_player, :world_ranking has_many :players has_many :results class Result < ActiveRecord::Base attr_accessible :round, :score, :team_name belongs_to :team has_many :players class Player < ActiveRecord::Base attr_accessible :first_name, :last_name, :position, :player_number, :team_name belongs_to :team end my default view is team#index and i have the option to show the team what I want to achieve is to show the team details plus the team''s players and results for the tournament (pretty much the content of the other 2 tables) and am having an awful lot of trouble trying to render the info. tried partials and a few methods but to no avail Any ideas how can I go about this issue? Thanking you in advance! Jax -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/3Z0i72p-3AkJ. For more options, visit https://groups.google.com/groups/opt_out.
In the index view of team write the code of index view of player and select only the team players by @team.player: <table> <tr> <th>Name</th> <th>Position</th> <th>Number</th> </tr> <% @team.players.each do |team_player| %> <tr> <td><%= team_player.first_name %> <%= team_player.last_name %></td> <td><%= team_player.position %></td> <td><%= team_player.number %></td> </tr> <% end %> </table> For the results it''s he same. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
It worked a treat! thanks a million! Jax On Friday, February 15, 2013 9:52:44 AM UTC, Ruby-Forum.com User wrote:> > In the index view of team write the code of index view of player and > select only the team players by @team.player: > > <table> > <tr> > <th>Name</th> > <th>Position</th> > <th>Number</th> > </tr> > <% @team.players.each do |team_player| %> > <tr> > <td><%= team_player.first_name %> <%= team_player.last_name > %></td> > <td><%= team_player.position %></td> > <td><%= team_player.number %></td> > </tr> > <% end %> > </table> > > For the results it''s he same. > > -- > Posted via http://www.ruby-forum.com/. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/EukZiIIssncJ. For more options, visit https://groups.google.com/groups/opt_out.