Skip to content

Instantly share code, notes, and snippets.

@gangelo
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save gangelo/50c95791589381ccd1db to your computer and use it in GitHub Desktop.

Select an option

Save gangelo/50c95791589381ccd1db to your computer and use it in GitHub Desktop.
Rails Tidbits
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