Module: Padrino::Flash::Helpers

Defined in:
lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb

Overview

Storage

Instance Method Summary collapse

Instance Method Details

#flashStorage

Returns the flash storage object

Returns:

Since:

  • 0.10.8



224
225
226
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 224

def flash
  @_flash ||= Storage.new(env['rack.session'] ? session[:_flash] : {})
end

#redirect(url) ⇒ Object #redirect(url, status_code) ⇒ Object #redirect(url, status_code, flash_messages) ⇒ Object #redirect(url, flash_messages) ⇒ Object Also known as: redirect_to

Overloads the existing redirect helper in-order to provide support for flash messages

Examples:

redirect(dashboard, success: :user_created)
redirect(new_location, 301, notice: 'This page has moved. Please update your bookmarks!!')

Overloads:

  • #redirect(url) ⇒ Object

    Parameters:

  • #redirect(url, status_code) ⇒ Object

    Parameters:

    • url (String)
    • status_code (Fixnum)
  • #redirect(url, status_code, flash_messages) ⇒ Object

    Parameters:

    • url (String)
    • status_code (Fixnum)
    • flash_messages (Hash)
  • #redirect(url, flash_messages) ⇒ Object

    Parameters:

    • url (String)
    • flash_messages (Hash)

Since:

  • 0.10.8



205
206
207
208
209
210
211
212
213
214
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb', line 205

def redirect(url, *args)
  flashes = args.extract_options!

  flashes.each do |type, message|
    message = I18n.translate(message) if message.is_a?(Symbol) && defined?(I18n)
    flash[type] = message
  end

  super(url, args)
end