Undefined method with Active Record joins

Rooms: id, name (has_many :rentals, belongs_to :units)
People: id, name (has_many :rentals)
Rentals: room_id, people_id, created_at, ended_at (belongs_to :rooms,

:people)

So Rentals is a join table between Rooms 6 people, correct?

try this:

Rooms:
has_many :rentals
has_many :people, :through => :rentals

People:
has_many :rentals
has_many: rooms, :through => :rentals

that should enable you to do @unit.rooms.people

Can't do that. Proxies only work one level deep. When you think about it,
@unit.rooms returns a bunch of Room objects. Invoking a single association
on a collection of objects doesn't make sense. You need to iterate them.

At least that's how it looks to me from your class definitions.

Jacquie Fan wrote: