daily pastebin goal
42%
SHARE
TWEET

Untitled

a guest Aug 15th, 2018 59 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. Rails difference in object created from a .find(:id) and .where() methods
  2. tec = Technique.find(6)
  3. tec2 = Technique.where(:korean => 'Jok Sul')
  4.    
  5. tec2 = Technique.where(:korean => 'Jok Sul').first
  6.    
  7. tec_scope = Technique.where(:korean => 'Jok Sul') # create an internal query
  8.    
  9. tec_scope.all # returns array
  10. tec_scope.first # retuns one element
  11.    
  12. tec_objects = Technique.find(6) # explicitly runs a query and returns one object (in this case)
  13.    
  14. Technique.find([4,5]) # will return an array
  15. Technique.find(4) # will return one object
  16. Technique.where(:some_key => "some value").all # will return an array
  17. Technique.where(:id => 5).first # will return one object
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top