Last active
August 29, 2015 14:07
-
-
Save gangelo/50c95791589381ccd1db to your computer and use it in GitHub Desktop.
Rails Tidbits
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
| Flash[:notice] vs. Flash.now[:notice] | |
| ============================================ | |
| Flash[:notice] - message will persist to the next action and should be used when redirecting to another action via the 'redirect_to' method. | |
| Flash.now[:notice] - message will be displayed in the view your are rendering via the 'render' method. | |
| Log and watch messages logged realtime | |
| ============================================ | |
| # In my code... | |
| logger.info 'My logged message' | |
| # From the command-line... | |
| $ tail -f log/test.log | |
| RSpec | |
| ============================================ | |
| # Test flash message | |
| expect(request.flash[:notice]).to start_with("Success!") | |
| # Test flash.now message | |
| expect(request.flash.now[:error]).to start_with("Aww, shucks!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment