Probably it should looks like this:
class Item
property :name, String
belongs_to :parent, Item
end
class Container < Item
has_many :items, Item
end
class Image < Item; end
class Post < Item; end
class Folder < Container; end
But i failed to achieve this with Og :(
P.S.
Does ActiveRecords or DataMapper support this feature?
Thanks!
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Nitro-general mailing list
Nitro-...@rubyforge.org
http://rubyforge.org/mailman/listinfo/nitro-general
class Item
property :name, String
belongs_to :parent, Object
end
class Container < Item
has_many :items, Item
end
class Folder < Item
has_many :items, Item
end
But, there are major disadvantages:
- Code duplication, each 'Container' should explicitly include 'has_many
...'.
- Instead of 'Item' you forced to use 'Container::Item' and
'Folder::Item' and remember about it.
- Instead of one 'Item' table you got two distinct 'container_item' and
'folder_item' tables.
So, this is not the best solution ... :(