Trying to show 3 tables in 1 view

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

In the index view of team write the code of index view of player and
select only the team players by @team.player:

<% @team.players.each do |team_player| %> <% end %>
Name Position Number
<%= team_player.first_name %> <%= team_player.last_name %> <%= team_player.position %> <%= team_player.number %>

For the results it’s he same.

It worked a treat! thanks a million!

Jax