This will probably be an easy one as I must be overlooking something
obvious. I’m trying to set up a helper method that file find the first
photo belonging to a product ( photo.sort should == 1).
Why would the table “photos” have a photo_id field in it? This is what
it
looks like when you’re doing the find.
This method should be put in the photo model… or are you trying to get
the
photo for a specific product? If you are, then it should go in the
product
model and shouldn’t actually be a method at all!
Define a has_one :photo or has_many :photos on the product model. You
will
then be able to access all related photos by doing @product =
Product.find
(:first) @product.photos