Module: FlashHelper
- Included in:
- Kuppayam::BaseController
- Defined in:
- app/helpers/flash_helper.rb
Instance Method Summary collapse
-
#flash_message(now = true) ⇒ Object
Example
<%= flash_message() -%>. -
#get_flash_message(now = true) ⇒ Object
Example ajax_notice = get_flash_message(true) notice = get_flash_message(false).
-
#set_flash_message(message, type, now = true) ⇒ Object
This function will set a flash message depending up on the request type (ajax - xml http or direct http) Example set_flash_message("The message has been sent successfully", :success, false) set_flash_message("Permission denied", :error).
Instance Method Details
#flash_message(now = true) ⇒ Object
Example
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/helpers/flash_helper.rb', line 33 def (now=true) = (now) cls_name = "alert-info" cls_name = 'alert-success' if flash.now[:success] || flash[:success] cls_name = 'alert-warning' if flash.now[:alert] || flash[:alert] cls_name = 'alert-danger' if flash.now[:error] || flash[:error] = .strip if content_tag(:div, class: "alert #{cls_name} mb-10", "data-alert" => "alert") do raw(link_to("×", "#", class: "close", "data-dismiss" => "alert") + content_tag(:p, )) end unless .blank? end |
#get_flash_message(now = true) ⇒ Object
Example ajax_notice = get_flash_message(true) notice = get_flash_message(false)
20 21 22 23 24 25 26 27 |
# File 'app/helpers/flash_helper.rb', line 20 def (now=true) if now = flash.now[:success] || flash.now[:notice] || flash.now[:alert] || flash.now[:error] else = flash[:success] || flash[:notice] || flash[:alert] || flash[:error] end end |
#set_flash_message(message, type, now = true) ⇒ Object
This function will set a flash message depending up on the request type (ajax - xml http or direct http) Example set_flash_message("The message has been sent successfully", :success, false) set_flash_message("Permission denied", :error)
Difference between flash and flash.now http://trace.adityalesmana.com/2010/10/difference-between-flash-and-flash-now-in-ruby/
9 10 11 12 13 14 15 |
# File 'app/helpers/flash_helper.rb', line 9 def (, type, now=true) if now flash.now[type] = else flash[type] = end end |