On Tuesday, 19 June 2012 20:29:25 UTC-4, John Merlino wrote:
>
> Hey all, 
>
> I saw this piece of code: 
>
> @user = User.find(params[:user_id]) rescue nil 
>
> why rescue with a nil here? 


Because the author forgot about find_by_id, which would accomplish the 
exact same thing (returning nil if no record was found).

--Matt Jones 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/8gD2kFdxxOcJ.
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