はbetween..Hereの抽象化で別の使用して2つの仲介のモデルに一つのモデルに参加している:私はCountry.firstを行うことができるようにしたい2つのモデル間に複数のモデルを持つhas_many関係を作成するにはどうすればよいですか? (RailsのActiveRecordの上のルビー)私が何をしたいのですがどのような
Country has_many Companies Company has_many Buildings, Company belongs_to Country Building has_many Rooms, Building belongs_to Company Room belongs_to Building
rooms
.building_id = building
.ID WHERE((ON buildings
を登録しようrooms
INNER FROM SELECT *:しかし、これはのようなSQLを生成しようと
class Country - ActiveRecord::Base has_many :companies has_many :buildings, :through=>:companies has_many :rooms, :through=>:buildings end
:.roomsので、私は国のモデルはのような単純なものだろうと思いましたbuilding
.country_id = 1))
明らかに、building.country_idは存在しません...どうすればこの問題を回避できますか?
Rails(具体的にはActiveRecord)のバージョンは何ですか? – steel