Module: Librails::ApplicationHelper
- Defined in:
- lib/librails/application_helper.rb
Instance Method Summary collapse
- #bootstrap_class_for(flash_type) ⇒ Object
- #bs5_flash_messages(opts = {}) ⇒ Object
- #flash_messages(opts = {}) ⇒ Object
- #ransack_value(params, value_param, query_param = 'q') ⇒ Object
Instance Method Details
#bootstrap_class_for(flash_type) ⇒ Object
4 5 6 |
# File 'lib/librails/application_helper.rb', line 4 def bootstrap_class_for(flash_type) { success: "alert-success", error: "alert-danger", alert: "alert-warning", notice: "alert-info" }[flash_type.to_sym] || flash_type.to_s end |
#bs5_flash_messages(opts = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/librails/application_helper.rb', line 24 def (opts = {}) # https://github.com/plataformatec/devise/issues/1777 # deviseが:timeoutにtrueをぶちこんでくるのでそれを除外する flash.each do |msg_type, | next if msg_type == :timedout concat(content_tag(:div, , class: "alert #{bootstrap_class_for(msg_type)} alert-dismissible", role: 'alert') do concat(content_tag(:button, class: 'btn-close', data: { bs_dismiss: 'alert' }, aria_label: 'Close') do end) concat end) end nil end |
#flash_messages(opts = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/librails/application_helper.rb', line 8 def (opts = {}) # https://github.com/plataformatec/devise/issues/1777 # deviseが:timeoutにtrueをぶちこんでくるのでそれを除外する flash.each do |msg_type, | next if msg_type == :timedout concat(content_tag(:div, , class: "alert #{bootstrap_class_for(msg_type)} alert-dismissible", role: 'alert') do concat(content_tag(:button, class: 'close', data: { dismiss: 'alert' }) do concat content_tag(:span, '×'.html_safe, 'aria-hidden' => true) concat content_tag(:span, 'Close', class: 'sr-only') end) concat end) end nil end |
#ransack_value(params, value_param, query_param = 'q') ⇒ Object
37 38 39 40 41 42 |
# File 'lib/librails/application_helper.rb', line 37 def ransack_value(params, value_param, query_param = 'q') q = params[query_param] return nil unless q return nil unless q.kind_of?(ActionController::Parameters) q[value_param] end |