Has_one :through through a join model?

Your situation suggests using polymorphic associations, which are much cleaner than has_many :through associations. For example: class Person has_many :emails, :as => :emailable end class Company has_many :emails, :as => :emailable end class Email belongs_to :emailable, :polymorphic => true end You can get rid of your PersonEmails class entirely. In the database, your emails table will look something like this: create_table :emails do |t| t.

String :address t. String :emailable_type t. Integer :emailable_id end The emailable_type column stores the name of the associated model, in your case Person or Company and the emailable_id stores the id of the associated object.

For more information see the Rails API documentation under "Polymorphic Associations.

Your situation suggests using polymorphic associations, which are much cleaner than has_many :through associations. For example: class Person has_many :emails, :as => :emailable end class Company has_many :emails, :as => :emailable end class Email belongs_to :emailable, :polymorphic => true end You can get rid of your PersonEmails class entirely. In the database, your emails table will look something like this: create_table :emails do |t| t.

String :address t. String :emailable_type t. Integer :emailable_id end The emailable_type column stores the name of the associated model, in your case "Person" or "Company", and the emailable_id stores the id of the associated object.

For more information see the Rails API documentation under "Polymorphic Associations".

I don't know ruby, but as far as the database design part of your question, this question on stackoverflow may help you.

Click Here Your credit card information will remain strictly confidential and will not be sold or distributed. You will never receive any unsolicited material.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions