Module: Roda::RodaPlugins::Flash

Defined in:
lib/roda/plugins/flash.rb

Overview

The flash plugin adds a flash instance method to Roda, for typical web application flash handling, where values set in the current flash hash are available in the next request.

With the example below, if a POST request is submitted, it will redirect and the resulting GET request will return 'b'.

plugin :flash

route do |r|
r.is '' do
  r.get do
    flash['a']
  end

  r.post do
    flash['a'] = 'b'
    r.redirect('')
  end
end
end

You can modify the flash for the current request (instead of the next request) by using the flash.now method:

r.get do
flash.now['a'] = 'b'
flash['a'] # = >'b'
end

Defined Under Namespace

Modules: InstanceMethods Classes: FlashHash

Constant Summary collapse

SCOPE_INSTANCE_VARIABLES =
[:@_flash].freeze