On Fri, Feb 27, 2009 at 2:33 PM, Tony Tony <rails-mailing-l...@andreas-s.net
> wrote:

>
> Thanks for the replies!
>
> Craigs solution worked like a charm.


Cool.


> First time I use foreign_key.  I have a feeling that while this worked,
> the way it works (specifically having to specify foreign_key) is
> incorrect or rather defaults rails conventions. Is this the case? If so
> what can or should I do to make this work from now on?


Using the :foreign_key option isn't incorrect. It's there if you need to
circumvent the Rails defaults for any reason. If you didn't want to use the
:foreign_key option, you could use a migration to rename the color_id and
color2_id columns in your shirts table to primary_color_id and
secondary_color_id, respectively. Then, you could just declare your
associations like this:

class Shirt < ActiveRecord::Base
  belongs_to :primary_color, :class_name => "ApprovedColor"
  belongs_to :secondary_color, :class_name => "ApprovedColor"
end

Regards,
Craig

--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to