1
나는 별도의 모델을 만드는 대신 여기에서 찾은 국가의 보석을 사용하고 싶습니다.레일 3 몽고와 국가 보석
잘 상속받을 수 있지만 다른 클래스를 소유 할 수 있기를 바랍니다.
이것이 가능합니까? IE는 다음과 같습니다. 하위 클래스에 키를 제공하기 위해 사용할 수있는 방법이 있습니까? 정의되지 않은 메서드`has_many '국가 : 클래스
또는 객체가 초기화 된 후 보석의 속성을 상속/포함 할 수있는 방법 순간
https://github.com/hexorx/countries
class Country < ISO3166::Country
#include Mongoid::Document
#RELATIONS
has_many :cities
has_many :reviews, as: :reviewable
end
나는 NoMethodError을 얻을? 나에게
class Country# < ISO3166::Country
include Mongoid::Document
#field :name, :type => String
field :country_id, :type => String
##RELATIONS
has_many :cities
has_many :reviews, as: :reviewable
def after_initialize
ISO3166::Country.find_country_by_alpha3(self.country_id)
end
end