私は次のものを持っています:
belongs_to :type, :class_name => :activity_type
belongs_to :activity_type # needed for has_one :through?
has_one :category, :through => :activity_type, :class_name => :activity_category
「activity_type」の代わりに「type」を使用して、この「has_one through」関係を行う方法はありますか?
編集:これは機能していませんでした。「タイプ」という魔法の言葉のおかげで見れませんでした。
私が今持っているのはこれです:
belongs_to :company
belongs_to :type, :class_name => 'ActivityType', :foreign_key => 'activity_type_id'
has_one :category, :through => :type, :class_name => 'ActivityCategory', :foreign_key => 'activity_category_id'
しかし、それは失敗します
no such column: activity_types.category_id
予想される列は「activity_types.activity_category_id」になるため、これは正しいです。どうすれば修正できますか?