Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Rails difference in object created from a .find(:id) and .where() methods
- tec = Technique.find(6)
- tec2 = Technique.where(:korean => 'Jok Sul')
- tec2 = Technique.where(:korean => 'Jok Sul').first
- tec_scope = Technique.where(:korean => 'Jok Sul') # create an internal query
- tec_scope.all # returns array
- tec_scope.first # retuns one element
- tec_objects = Technique.find(6) # explicitly runs a query and returns one object (in this case)
- Technique.find([4,5]) # will return an array
- Technique.find(4) # will return one object
- Technique.where(:some_key => "some value").all # will return an array
- Technique.where(:id => 5).first # will return one object
Add Comment
Please, Sign In to add comment