I am new to Rails and this is my first major project. I have a piece
of content that can have multiple titles based on the language. I have
four models Content, Titles, Language and TitleTranslation.
class Content < ActiveRecord::Base
has_many :title_translations
has_many :languages, :through => :title_translations
has_many :titles, :through => :title_translations
end
class Language < ActiveRecord::Base
has_many :title_translations
has_many :contents, :through => :title_translations
has_many :titles, :through => :title_translations
end
class Titile < ActiveRecord::Base
has_many :title_translations
has_many :languages, :through => :title_translations
has_many :contents, :through
=> :title_translations
end
class TitleTranslation < ActiveRecord::Base
belongs_to :content, :title, :language
end
Here is the title_translation table:
class CreateTitleTranslations < ActiveRecord::Migration
def self.up
create_table :title_translations do |t|
t.column :content_id, :integer
t.column :language_id, :integer
t.column :title_id, :integer
t.column :created_at, :timestamp
end
end
def self.down
drop_table :title_translations
end
end
Is this the way i need to set it up? If so how do i access them? I
have searched the internet and no one seems to give you that. Please
let me know if i need to supply more info… thanks…