I have two models that share some of the same attributes so I wanted to setup a single table inheritance structure. After doing some research, I found out that I can use module to achieve the same by doing the following instead:
module CommonFields
def self.included base
base.class_eval do
include DataMapper::Resource
property :type, base::Discriminator
property :enable_feature1, base::Boolean, :default => false
property :enable_feature2, base::Boolean, :default => false
end
end
end
class A
include CommonFields
property: title, String
end
class B
include CommonFields
end
However, when I do rake db:automigrate I get:
undefined method `properties' for CommonFields:Module /usr/local/rvm/gems/ruby-1.9.2-p290/gems/dm-core-1.2.0/lib/dm-core/associations/relationship.rb:252:in `parent_key'
Any ideas?
Thanks,
Paul