Ruby on rails rails activerecord包括3个级别
我有这些联想Ruby on rails rails activerecord包括3个级别,ruby-on-rails,activerecord,join,Ruby On Rails,Activerecord,Join,我有这些联想 class Incident < Activerecord::Base belongs_to :building class Building < Activerecord::Base has_many :incidents belongs_to :contact class Contact < Activerecord::Base has_many :buildings belongs_to :company cl
class Incident < Activerecord::Base
belongs_to :building
class Building < Activerecord::Base
has_many :incidents
belongs_to :contact
class Contact < Activerecord::Base
has_many :buildings
belongs_to :company
class Company < Activerecord::Base
has_many :contacts
不幸的是,这不起作用
ActiveRecord::ConfigurationError - Association named 'company' was not found; perhaps you misspelled it?
我不知道为什么,但是“包含”方法可以有两个级别的关联,而不是三个级别
我怎样才能解决这个问题
谢谢只是一个简单的例子:但是你能尝试一下
包含(:building=>{:contact=>:company})
希望你需要使用:通过关联。嗨,本杰明,这是答案。我不知道我为什么不去想它。愚蠢的我。。。谢谢
ActiveRecord::ConfigurationError - Association named 'company' was not found; perhaps you misspelled it?