Module: Reusable::Rails::Controllers::FlashMessages
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/reusable/rails/controllers/flash_messages.rb
Instance Method Summary collapse
-
#flash_message(type, text) ⇒ Hash
Helper for supporting multiple flash messages per type.
-
#flash_messages(options = {}) ⇒ Object
Return any flash messages added for the request, optionally can be formatted to return a JSON representation.
Methods included from ActiveSupport::Concern
append_features, extended, included
Instance Method Details
#flash_message(type, text) ⇒ Hash
Helper for supporting multiple flash messages per type
:success, :notice, :error
16 17 18 19 |
# File 'lib/reusable/rails/controllers/flash_messages.rb', line 16 def (type, text) flash[type.to_sym] ||= [] flash[type.to_sym] << text end |
#flash_messages(options = {}) ⇒ Object
Return any flash messages added for the request, optionally can be formatted to return a JSON representation.
25 26 27 28 29 30 31 32 33 |
# File 'lib/reusable/rails/controllers/flash_messages.rb', line 25 def (={}) if !![:json] Hash[flash.collect do |type, | [k, .is_a?(Array) ? .collect {|i| ERB::Util.h(i)} : ERB::Util.h()] end].to_json else flash end end |