Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3.1 Devise How To Change Flash Message CSS From notice to success?

Rails 3.1 and Devise 1.5 question.

I'm using the following code to display flash messages in my layout:

    <% flash.each do |key, message| %>
      <%= content_tag(:div, message, :class => "flash #{key}") %>
    <% end %>

I'd like to change the css class for some of my confirmation messages from notice to success, but I don't know where to override or change the key because I don't know where it's set.

Can anybody point me in the right direction?

Thanks!

like image 892
jacoulter Avatar asked Dec 05 '11 14:12

jacoulter


1 Answers

So the way to do this is to edit the devise controllers.

When you install Devise through the normal installation I don't think it install the controllers (at least it didn't for me).

So first you should manually add the controller files and put them into your project in the same location: https://github.com/plataformatec/devise/tree/master/app/controllers/devise

Once you have the files in your project, go to the "sessions_controller.rb" file.

One lines 16 & 25, you should see the code:

set_flash_message :notice, :signed_in

and

set_flash_message :notice, :signed_out

You just need to change ":notice" to ":success"

Hope that works!

like image 117
Zephyr4434 Avatar answered Sep 29 '22 02:09

Zephyr4434