Last active
December 15, 2015 03:05
-
-
Save deep-spaced/87f94478562de0794397 to your computer and use it in GitHub Desktop.
Ruby Boolean logic
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
return Photo.find(params[:photo][:id]) or Photo.new | |
# Valid parameter: instance from database | |
# Invalid parameter: new instance | |
return photo = Photo.find(params[:photo][:id]) and photo.update(comment: params[:photo][:comment]) and photo | |
# Valid ID and successful update: photo instance | |
# Valid ID and failed update: result of update | |
# Invalid ID: nil | |
# Yes, I work in Rails. You got a problem with that?!? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment