Select from 3 table! has_many throug

class Place < ActiveRecord::Base
  attr_accessible :address, :city, :name, :description
  has_many :meetings
end

Class Meeting < ActiveRecord::Base
  attr_accessible :start_at, :place_id, :title, :end_at

  belongs_to :place
  has_many :participations
  has_many :players, :through => :participations

end

class Participation < ActiveRecord::Base
  attr_accessible :meeting_id, :player_id
end

class Player < ActiveRecord::Base
  attr_accessible :id, :city, :first_name, :gear, :last_name, :email,
:password, :password_confirmation

  has_many :participations
  has_many :meetings, :through => :participations
end

how to select all meetings in the specified city together with their
addresses and players?

class Place < ActiveRecord::Base
  attr_accessible :address, :city, :name, :description
  has_many :meetings
end

Class Meeting < ActiveRecord::Base
  attr_accessible :start_at, :place_id, :title, :end_at

  belongs_to :place
  has_many :participations
  has_many :players, :through => :participations

end

class Participation < ActiveRecord::Base
  attr_accessible :meeting_id, :player_id

You need belongs_to metting and player here.

end

class Player < ActiveRecord::Base
  attr_accessible :id, :city, :first_name, :gear, :last_name, :email,
:password, :password_confirmation

  has_many :participations
  has_many :meetings, :through => :participations
end

how to select all meetings in the specified city together with their
addresses and players?

By a city do you mean a Place or a string in player.city?

Colin

Colin Law wrote in post #1079115:

  has_many :players, :through => :participations

end

class Participation < ActiveRecord::Base
  attr_accessible :meeting_id, :player_id

You need belongs_to metting and player here.

Sure thing, sorry cleaned it up by mistake.

how to select all meetings in the specified city together with their
addresses and players?

By a city do you mean a Place or a string in player.city?

Colin

I mean a Place, as a Meeting occurs in some Place, so it will be all
Meetings in all Places filtered out by the city.
Also I discover that it is possible to use counter_cache to have a
number of Players, who joined the Meeting in the player_cache column, is
that right?

Colin Law wrote in post #1079115:

  has_many :players, :through => :participations

end

class Participation < ActiveRecord::Base
  attr_accessible :meeting_id, :player_id

You need belongs_to metting and player here.

Sure thing, sorry cleaned it up by mistake.

how to select all meetings in the specified city together with their
addresses and players?

By a city do you mean a Place or a string in player.city?

Colin

I mean a Place, as a Meeting occurs in some Place, so it will be all
Meetings in all Places filtered out by the city.

You are using the word city again, so once again it is not clear what you mean.

Back to the original question, if you have a place, @place for
example, then its meetings are @place.meetings and for each meeting
the players are meeting.players. You have also asked for the address
of the meeting, but you know that already as it is in @place.

Also I discover that it is possible to use counter_cache to have a
number of Players, who joined the Meeting in the player_cache column, is
that right?

I have not used counter_cache but i believe it can be used for such things.

Colin