Skip to content

Instantly share code, notes, and snippets.

@jxson
Created January 24, 2009 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jxson/51302 to your computer and use it in GitHub Desktop.
Save jxson/51302 to your computer and use it in GitHub Desktop.
# Notes on ActiveRecord methods and idioms
# Raises an exception if there is a problem
Model.create!(attrs)
# Returns true or false (no exceptions are raised)
Model.create(attrs)
# the !! forces a return of true or false even if nil
def give_me_boolean_or_give_me_death(foo)
!!foo
end
# >> give_me_boolean_or_give_me_death nil
# => false
# >> give_me_boolean_or_give_me_death true
# => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment