or User.find_by! hash: hash

http://edgeapi.rubyonrails.org/classes/ActiveRecord/FinderMethods.html#method-i-find_by-21
  

Francesco Rodríguez
"The Most Powerfull Rookie"


@frodsan (http://twitter.com/#!/frodsan)
https://github.com/frodsan
http://www.frodsan.com/



On Wednesday, March 6, 2013 at 11:06 PM, Tejas Dinkar wrote:

> On Mar-07-2013, at 9:08 AM, Nick Ostrovsky <[email protected] 
> (mailto:[email protected])> wrote:
> > User.where(hash: hash) # .first
>  
>  
>  
>  
> Wouldn't it be more intuitive to use the #first! method for this purpose?
>  
> i.e., User.find_by_hash!(hash) is the same as User.where(hash: hash).first!
>  
> I know that I often chain where conditions together (especially when using 
> scopes), so it makes sense to raise the exception only when I actually try to 
> fetch the record from the database.
> --
> Tejas Dinkar
> http://c42.in
> C42 Engineering - The guys behind RubyMonk
>  
> --  
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> (mailto:[email protected]).
> To post to this group, send email to [email protected] 
> (mailto:[email protected]).
> Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  



-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to