摘要: 需求:有基类B,然后有三个子类CA,CB,CC。需要将他们关联起来。使用多态关联。起初我想的是将CA,CB,CC 分别 belongs_to B,但这样的话B就无法显式表示与子类的关联关系。通过多态关联.class BaseClass< ActiveRecord::Base belongs_to :childclass, :polymorphic => true endclass ChildClassA< ActiveRecord::Base has_one :BaseClass, :as => :childclassend class ChildClassB< 阅读全文
posted @ 2013-04-13 16:27 jzlikewei 阅读(271) 评论(0) 推荐(0) 编辑