1
동일한 속성을 공유하는 두 개의 모델이 있으므로 하나의 테이블 상속 구조를 설정하고 싶습니다. 그러나모델 간의 속성 공유 - Datamapper
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
, 내가 갈퀴 DB를 수행 할 때 : automigrate를 내가 얻을 :
정의되지 않은 메서드`특성을 몇 가지 연구를하고 후에, 나는 내가 대신 다음을 수행하여 동일한을 달성하기 위해 모듈을 사용할 수 있다는 것을 발견 'for CommonFields : 모듈 /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 '
아이디어가 있으십니까?
감사합니다,
폴
같은 문제는 ... 어떻게하셨습니까? –