Stupid Question - Need to get a field from table...

I’d make the following changes so that I could use more meaningful names for the colors:

Models

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