【发布时间】:2013-02-22 10:59:29
【问题描述】:
这是我想要做的:
class Cashflow < ActiveRecord::Base
belongs_to from_account, :class_name => 'Account'
belongs_to to_account, :class_name => 'Account'
end
class Account < ActiveRecord::Base
has_many :cashflows
end
其中Account::cashflows 显然是所有cashflows 的列表,这些account_id 存储在from_account 或to_account 中。
我很困惑。处理这种情况的正确方法是什么?这是多么糟糕的设计?设计这种关系的正确方法是什么?
【问题讨论】:
标签: ruby-on-rails model model-associations