Polymorphic Assocations using Integer ID type fields

后端 未结 4 1660
面向向阳花
面向向阳花 2020-12-19 01:54

I have a table Foo that has a polymorphic belongs_to association called bar. The foos table has the standard bar_id colum

4条回答
  •  自闭症患者
    2020-12-19 02:21

    There are two approaches for this.

    First is easy:

    has_many :bars, :conditions => "whatever you want"
    

    Second could be tricky:

    set_inheritance_column :bar_type_id
    

提交回复
热议问题