I am trying to get the right association for my models and can't figure it out.
I have 3 models, Bat
, Manufacturer
, & Review
. Here are my models:
class Bat < ActiveRecord::Base
has_many :reviews
has_one :manufacturer
end
class Manufacturer < ActiveRecord::Base
has_many :bats
end
class Review < ActiveRecord::Base
belongs_to :bat
end
In the Review model, it has a bat_id
& manufacturer_id
field. In the Bat model, it has a manufacturer_id
field.
I am trying to properly link the manufacturer model to the bat model.I have looked at http://guides.rubyonrails.org/association_basics.html#self-joins and I am not sure that is the type of relationship that I need.
Is this correct or am I missing something?