Skip to content

Instantly share code, notes, and snippets.

@luckydev
Created July 18, 2011 06:07
Show Gist options
  • Save luckydev/1088655 to your computer and use it in GitHub Desktop.
Save luckydev/1088655 to your computer and use it in GitHub Desktop.
ActiveRecord Finder
ruby-1.9.2-p180 :001 > Account.find(34)
ActiveRecord::RecordNotFound: Couldn't find Account with ID=34
from /Users/lakshman/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.5/lib/active_record/relation/finder_methods.rb:296:in `find_one'
from /Users/lakshman/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-
ruby-1.9.2-p180 :002 > Account.where(:id => 34).first
=> nil
ruby-1.9.2-p180 :003 > Account.where(:id => 34)
=> []
acc = Account.find(34)
acc = Account.where(:id => 34).first
acc = Account.where(:id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment