Created
November 25, 2014 16:39
-
-
Save anthonyjsmith/53fccd30ee0873b06c8b to your computer and use it in GitHub Desktop.
Non-expiring flash
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
# Visit: | |
# /main/set_flash | |
# /main/show_no_flash (as many times as you like) | |
# /main/show_flash ... and it shows the flash message | |
# (Rails 4.1.8, Ruby 2.1.1) | |
# app/controllers/main_controller.rb | |
class MainController < ApplicationController | |
def show_flash | |
render inline: flash[:notice] || "Flash is blank!" | |
end | |
def set_flash | |
flash[:notice] = "FLASH!" | |
render inline: "Nothing to see here" | |
end | |
def show_no_flash | |
render inline: "Nothing to see here" | |
end | |
end | |
# config/routes.rb | |
Rails.application.routes.draw do | |
get 'main/set_flash' | |
get 'main/show_flash' | |
get 'main/show_no_flash' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment