Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Custom flash messages with devise Gem

Hi,

I would like to change the flash message immediately after login to 'welcome back John!'. (think it has something to do with devise yml file, but I don't know how to add that user name/email variable. How could I do this?

Thanks in advance!

2 Answers

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

I managed to solve this and, as promised, I described everything in a blog post. This was very educating for me. Fir the first time I looked at Devise internals and even did some overriding of its methods. Let me know if it worked for you: http://mczuchnowski.github.io/tutorials/2015/03/23/dynamic-flash-messages-in-devise/

I will remove the first answer so that people won't get confused when reading this thread in the future.

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

I did some digging and the only way to do this seems to require overwriting the whole devise's sessions controller. This is old, so the code will no longer work, but it explains the idea: http://stackoverflow.com/questions/6010407/devise-custom-flash-message

Thanks I'll check it out. I'll mark you're answer as best answer if it works out. Thanks again!

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

I will also check this out today for the newest version of Rails and Devise and make a blog post about it if it works. It fascinates me and I like challenges :)