Displaying 1 result from an estimated 1 matches for "bicycle_id".
2007 Jan 26
6
has_many :through query question
...nk this is obvious. but for some reason I''m not getting it.
Models: Bicycles, Accessories
Join Model: Upgrades
The idea is that you can upgrade your bike by adding an accessory, and
the upgrade price is often less than the accessory price would normally
be. So the Upgrades table has id, bicycle_id, accessory_id, and price.
class Bicycle
has_many :upgrades
has_many :accessories, :through => :upgrades
end
class Upgrade
belongs_to :bicycle
belongs_to :accessory
# price defined in table
end
Now my question is, I need to query the upgrades for a bicycle for a
specific accessory....