Oleg Pasko
Oleg Pasko

Reputation: 2911

Multiple has_many/joins or create new relation in Rails

What is the best way for next case. User belongs to family (by family_id), family (by building_id) belongs to building, building (by street_id) belongs to street... etc.

street.users is common and frequent action.

What is the rails way, – build own active record method based on multiple 'joins' or just add 'street_id' and has_many to the User model?

Upvotes: 2

Views: 75

Answers (1)

peresleguine
peresleguine

Reputation: 2403

has_many :users, through: :families should work in Street model. Take a look at this question for details.

Upvotes: 3

Related Questions