First - your models should be singularly named. Use Country instead
of Countries, as your model is of a single country not a group of
countries.
class Country < ActiveRecord::Base
has_one :countrydescription
end
class CountryDescription < ActiveRecord::Base
belongs_to :country
end
I’d be curious why you’re storing the description of the country in a
separate table instead of along with the Country model? Even if it’s
meta data I would think this is better kept with the Country model,
and just have a text field called “description” it’d keep things
simpler.
Also, You should consider fixing your naming to match the Ruby/Rails
naming conventions.
class Country < ActiveRecord::Base
has_one :countrydescription
end
class CountryDescription < ActiveRecord::Base
belongs_to :country
end
This reply was almost right, but I think it should be:
has_one :country_description
Class names should be camel case with the first character upper case and
the each word upper.
Example: SomeClassName
Attribute names and method names should be all lower case with
underscores separating each word (consider table column names to be
attributes).
Example: some_attribute_name
ncancelliere wrote:
First - your models should be singularly named. Use Country instead
of Countries, as your model is of a single country not a group of
countries.
class Country < ActiveRecord::Base
has_one :countrydescription
end
class CountryDescription < ActiveRecord::Base
belongs_to :country
end
I’d be curious why you’re storing the description of the country in a
separate table instead of along with the Country model? Even if it’s
meta data I would think this is better kept with the Country model,
and just have a text field called “description” it’d keep things
simpler.