Created
January 24, 2009 01:57
-
-
Save jxson/51302 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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