Rails Devise I18n Flash Messages with Twitter Bootstrap

后端 未结 6 689
轻奢々
轻奢々 2020-12-23 23:47

Hello I am new to ruby on rails and I am struggling to understand I18n\'s flash messages. I am using devise, rails 4, and twitter bootstrap.I understand that devise only use

6条回答
  •  悲&欢浪女
    2020-12-24 00:26

    Here's my 2 cents. Using a case statement to check if the flash names are the older syntax alertor notice and change them to success or danger if they are and leave everything else alone.

    <% flash.each do |name, msg| %> <% if msg.is_a?(String) %> <% end %> <% end %>

    and a helper method

    def flash_class_name(name)
        case name
        when 'notice' then 'success'
        when 'alert'  then 'danger'
        else name
        end
    end
    

提交回复
热议问题