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 User Authentication with Rails Adding User Support to Our Application Requiring Login

in which part of the video does Jason explains this code snippet? add_flash_types :my, :types

Hello, I was taking a look to the Teacher's notes and I found this code snippet

add_flash_types :my, :types

he did not explain that in the video, can someone tell me what's going on with that snipet?

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

I don't think he mentions this in any of the videos (it's a bit chaotic at times), but this is used in the code presented in this video. Basically: Rails gives you two flash message types built-in: notice and alert. And they let you write code like notice: "You must be logged in to access that page." . This method allows you to add your own, custom types of flash messages. You can name them here and then use in your code. This is what happens here - Jason adds :success flash message type and he may now use things like flash[:success] and success: "You registered successfully!" . Here's more:

http://www.rubydoc.info/docs/rails/4.1.7/ActionController/Flash/ClassMethods:add_flash_types

Thank yuo so much, now I got it!