On Fri, Jul 10, 2009 at 3:58 PM, Älphä Blüë<[email protected]> wrote:
> Looking at what you provides so far let's go ahead and diagram it > exactly the way you wrote it and see what's wrong here. I'm leaving off > activerecord base for sake of clarity... > > class Person > belongs_to :favorite_color, :class_name => "Color", :foreign_key => > "color_id" > has_many :addresses, :dependent => :destroy > end > > class Address > belongs_to :product > end > > class Color > #don't need anything > end > > ============================= > > First thing I don't see is your relationship models for Product or > FavoriteColor. So, creating them based off what you wrote above I see: > > class Product > has_many :addresses > end > > class FavoriteColor > has_many :persons > has_many :addresses, :through => :persons > end I thought I could do: belongs_to :favorite_color, :class_name => "Color", :foreign_key => color_id Which tells it to use the Color class for favorite_color ? I don't want a FavoriteColor model, just Color. I could have just used: class Person belongs_to :color If I was content with a color_id column name for favorite color on Person. > But, you have class Address belonging to Product but your association > for Person is stating that addresses belong to it. Which does address > really belong to? Well the reason I added Addresses 'belonging to" Product is so that it would put the FK product_id in the Address table. I guess I should just leave off belongs_to :person on the Address model? --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

