LoginSignup
1
1

More than 5 years have passed since last update.

Add Flash Type in Rails

Posted at

Add flash type in application controller

# app/controller/application_controller.rb
class ApplicationController
  add_flash_types :original_type, :second_one
end

How to use (Example)

-# app/views/layouts/application.html.haml
- if flash.present?
  - flash.each_with_index do |(type, msg), index| 
    %div(class="flash flash-#{type}")
      .alertBlock
        %p= msg
  :coffee
    if typeof timerID != 'undefined'
      clearTimeout timerID
    timerID = setTimeout ->
      $('.alert.floating').animate {
        opacity: 0
      }, 300, ->
        $('.alert.floating').css 'display', 'none'
    , 1700
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1