I'd like to use the countries gem I found here instead creating a separate model.
It works fine to inherit from but I'd also like to be able to have other classes belong_to it.
Is this possible? IE something like below. Is there some method I could use to provide a key to child classes?
https://github.com/hexorx/countries
class Country < ISO3166::Country
#include Mongoid::Document
#RELATIONS
has_many :cities
has_many :reviews, as: :reviewable
end
At the moment I get NoMethodError: undefined method `has_many' for Country:Class
Or some way to include/inherit the attributes from the gem after the object is initialized?
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