Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #returns an ActiveRecord::Relation object
- @blogs = Blog.all
- # Search for the blog within that ActiveRecord::Relation object, NOT the database
- @blogs.find_by(id: 1).title #do this statement but don't hit the database again
- @blogs.find {|b| b.id == 1}
- @blogs.detect { |b| b.id == 1 }
- @blogs.where(id: 1).first.reload
Add Comment
Please, Sign In to add comment