0

我有以下模型及其关系:

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

Anaccount拥有 a business,并且 abusiness有许多与之关联的客户。

在我的控制器中,设置客户实例后,我尝试执行以下操作:

@customer.business = @account.business

检查@customer.business, 和@account.business时,一切正常。但是,当我尝试做: 时@account.business.customers,我总是得到一个空数组。

4

1 回答 1

0

我假设您在为客户分配帐户业务后保存了客户?

于 2013-07-12T22:19:09.397 回答