Hello,
I’m just starting out with some Rails development and have the following
table structure. I understand how to do a two table has many join but I
actually need to relate a third table. Here is my structure:
components
id
name
updated_at
elements
id
name
updated_at
element_types
id
name
updated_at
components_elements
component_id
element_id
element_type_id
updated_at
My Component model has the following:
class Component < ActiveRecord::Base
has_and_belongs_to_many :elements
end
I haven’t actually added anything to my Element model but suspect that
it
also needs a habtm association. My bigger issue is, how to I associate
things with the element_types table?
Kyle H.
[email protected]
www.kyleheon.com