ok Datamapper::Property::Serial works.

now I have another problem.

module Base
def self.included(base)
base.class_eval do
include DataMapper::Resource
property :id, DataMapper::Property::Serial, :key => true
property :created_at, DateTime, :required => true
end
end
end

this is my base class and I'm extending it like,

class Product
include Base
property :name, String
end

this works perfectly. now I want to make things a bit more complicated like,

module BaseEntry
def self.included(base)
base.class_eval do
include Base
belongs_to :created_by, 'User'
end
end
end

and I want my Product model to extend BaseEntry now. It doesn't give any 
error and creates proper tables correctly on startup.

But... Product.create(:name => 'test') doesn't create a record this time. I 
tried including both Base and BaseEntry into Product model but it didn't 
work either.

I'm coming from java(JPA) and c#(EF code-first) worlds and abstract base 
classes are my favourite when I design data models so it would be great if I 
could find a way to code as I get used to. it's why I'm poking around with 
inheritance or DRY up posibilities of datamapper.

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to