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... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I think what you have is a ternary association. Look this: http://www.ruby-forum.com/topic/3439 Good luck! jonbaty wrote:> 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. > > 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...-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Seems reasonable enough to me. What doesn''t work? (I assume that in your source you have class Title not class Titile) Also you can''t do belongs_to :content, :title, :language. You need to do them one at a time Fred -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---