Ruby on rails 将对象分配给关联不起作用

Ruby on rails 将对象分配给关联不起作用,ruby-on-rails,ruby,activerecord,associations,Ruby On Rails,Ruby,Activerecord,Associations,我有以下模型及其关系: 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 c

我有以下模型及其关系:

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

检查
@customer.business
@account.business
时,一切正常。但是,当我尝试执行以下操作时:
@account.business.customers
,我总是得到一个空数组。

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

就是这样!我不知道这有什么关系。谢天谢地,它们必须在某个时刻被保存以获得ID,这就是将在关联中查询的内容。
@customer.business = @account.business