Say I have a model A::B which has_many model C, what do i name the foreign key?
Class A::B
has_many :c
Class C
belongs_to :a_b
In the database Table C has a column a_b_id.
This does not work. Any idea what i am missing? the :: are what i am confused about. Thanks!
Since
Bis in a different namespace, you’ll need to specify it in your classC.since you’re using
a_b_idand notb_id, you’ll need to specify the foreign key inA::BAlternatively, you could use the following set up to avoid having to specify a foreign key in
A::BThis would require
b_idin the table forC