Displaying 1 result from an estimated 1 matches for "place_name".
Did you mean:
iface_name
2006 Mar 23
4
belongs_to more than one model
Suppose I have one table:
states
id
statename
And I have two other tables that contains states:
houses
id
color
state_id
places
id
place_name
state_id
How would my model relationships look like?
class State < ActiveRecord::Base
belongs_to house
belongs_to place
end
class House < ActiveRecord::Base
has_one state
end
class Place < ActiveRecord::Base
has_one state
end
Is that right? Can I have a model that...