I am looking for a design approach for the following. I have three models [regions, groups, items] which are used to generate a tree menu (ancestry gem)
class Region < ActiveRecord::Base
has_many :groups
has_many :items
end
class Group < ActiveRecord::Base
belongs_to :region
has_many :items
has_ancestry
end
class Item < ActiveRecord::Base
belongs_to :region
belongs_to :group
end
As you can see I have a region assigned to both group and item for the purpose of building a menutree: Region(s) => Group(s) => Item(s).
The Item's region is used extensively throughout the application however the group's region is used only when rendering the menu.
I don't like that the group's region may be different to any of its item's regions or indeed any of its descendants. I have been assured that inheriting the region for the item from the group is not appropriate as an item may not have a group, nor can the group inherit its region from the unique regions of the item (since if there were items of different regions contained by the same group the same group would appear twice under different regions)
Can anyone suggest another approach to this?