Last active
March 22, 2018 17:19
-
-
Save rachidcalazans/6552fe267daf51ea7a74689aa5e0d566 to your computer and use it in GitHub Desktop.
Example I Avoiding Nil - Represent special cases as objects
This file contains hidden or 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
| def index | |
| if current_user | |
| @posts = current_user.posts | |
| else | |
| @posts = List.public_posts | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment