Skip to content

Instantly share code, notes, and snippets.

@kalmbach
Last active May 5, 2024 13:06
Show Gist options
  • Select an option

  • Save kalmbach/5385621 to your computer and use it in GitHub Desktop.

Select an option

Save kalmbach/5385621 to your computer and use it in GitHub Desktop.

Revisions

  1. kalmbach created this gist Apr 15, 2013.
    27 changes: 27 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    module Rack
    module Session
    class Flash
    def initialize(app)
    @app = app
    end

    def call(env)
    dup.call!(env)
    end

    def call!(env)
    env['rack.session'] || raise(RuntimeError,
    'You\'re missing a session handler. ' +
    'You can get started using Rack::Session::Cookie')

    env['rack.session']['flash'] ||= {}

    response = @app.call(env)

    env['rack.session']['flash'].clear

    response
    end
    end
    end
    end