我的关系有以下模型:
class Account < ActiveRecord::Base
has_one :business, :inverse_of => :account
end
class Business < ActiveRecord::Base
belongs_to :account, :inverse_of => :business
has_many :customers, :inverse_of => :business
end
class Customer < ActiveRecord::Base
belongs_to :business, :inverse_of => :customers
end
account
拥有business
,business
有许多客户与之关联。
在我的控制器中,在设置客户实例后,我尝试执行以下操作:
@customer.business = @account.business
检查@customer.business
和@account.business
时,一切正常。但是,当我尝试执行:@account.business.customers
时,我总是得到一个空数组。
答案 0 :(得分:0)
我假设您在分配了帐户业务后保存了客户?