has_one and find_by_id issue

I have two models:

testamonial photo (has_attachement)

testamonial has_one photo

The issue is when do this:     @testamonial = Testamonial.find_all_by_id(id)

I get "undefined method `photo' for" in my browser?? BUT here is the big kicker....

If I do @testamonial = Testamonial.find(:first)

everything works fine and the image is show!.. (find :all works too when I loop through the objects.)

I tried @testamonial = Testamonial.find_all_by_id(id, :include => :photo) That just gave me a bigger query and still no photo..

heimdull wrote:

If I do @testamonial = Testamonial.find(:first)

everything works fine and the image is show!.. (find :all works too when I loop through the objects.)

Are you sure the id matches the first record in the table?

I have two models:

testamonial photo (has_attachement)

testamonial has_one photo

The issue is when do this:    @testamonial = Testamonial.find_all_by_id(id)

I get "undefined method `photo' for" in my browser?? BUT here is the big kicker....

That returns an array of testamonials, not a single object as
find :first does.

Fred

And thats why I say never post to a forum in the middle of the night : (

duh...

Changed the view code and its all good now...

Thanks Fred