我有一个如下的帐户模型(简化):
class Account < ActiveRecord::Base
attr_accessible :account_number, :display_name, :master_account_id
has_many :child_accounts, :class_name => "Account", :foreign_key => "id"
belongs_to :master_account, :class_name => "Account", :foreign_key => "master_account_id"
end
@account.master_account
目前工作正常,但我也希望能够访问@account.child_accounts
- 我需要做什么才能解决这个问题?