Thanks for the info.  Unfortunately, I tried your suggestion but I still 
get the same error :(

undefined method 'properties' for CommonFields:Module

I am using datamapper 1.2.0 btw if it makes a difference.

On Thursday, 30 May 2013 17:35:34 UTC-4, postmodern wrote:
>
>  I usually include DataMapper::Resource outside of the class/module eval.
>
>  base.send :include, DataMapper::Resource
>
>  https://github.com/ronin-ruby/ronin/blob/master/lib/ronin/model/model.rb
> https://github.com/ronin-ruby/ronin/blob/master/lib/ronin/model/has_name.rb
>
> On 05/30/2013 10:30 AM, Paul wrote:
>  
> Hi, 
>
>  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
> -- 
> You received this message because you are subscribed to the Google Groups 
> "DataMapper" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to datamapper+...@googlegroups.com <javascript:>.
> To post to this group, send email to datam...@googlegroups.com<javascript:>
> .
> Visit this group at http://groups.google.com/group/datamapper?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
>
>
>
> -- 
> Blog: http://postmodern.github.com/
> GitHub: https://github.com/postmodern
> Twitter: @postmodern_mod3
> PGP: 0xB9515E77
>
>  

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to datamapper+unsubscr...@googlegroups.com.
To post to this group, send email to datamapper@googlegroups.com.
Visit this group at http://groups.google.com/group/datamapper?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to