On 27 Feb 2009, at 11:31, Petan Cert wrote:

>
> Hi all,
>
> I have two models gallery and photo (has_many -> belongs_to).
> Can I use this to find the primary photo for the given gallery?
>
> @gallery = @user.galleries
> @primary_photo = @gallery.photos.find_by_primary(true).first
>

find_by_xxx returns a single object (or nil) so that call to first is  
superfluous.

Fred
> it ends with error.
>
> Thanks for any help.
> P.
> -- 
> Posted via http://www.ruby-forum.com/.
>
> >


--~--~---------~--~----~------------~-------~--~----~
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