flash[ : error] = " Username and password do not match. slice( : notice, : message, : error, : success, : warning, : failure). each do | level, value| - if value. % div{ : class = > " flash # { h level} " } = h value - flash[ level]. But it can be used for more than that, any time that you redirect and want to pass along some state without making it part of the URL. But in Rails, flash messages are something completely different. By default, there are three different types: error, warning and notice. In Rails 3, the ability to set flash parameters : notice and : alert in a controller. Here is an example of setting a custom error flash type in Rails 3:. reinteractive: UI Tips for Flash messages in Rails. flash- message { &. error { border: solid 4px # 900; background- color: # FF6565; } &. Currently, redirect_ to accepts : notice, : alert, and : flash.
Why not accept usual : error? It is of course possible with redirect_ to url, flash = > { : error. Ruby on Rails has a special object called flash which hold its contents. I expect error messages and success messages to be near the forms. In Rails, the flash message is a convenient way to show messages on a page, typically as confirmation or error message after user actions. Adding flash message capability to your render calls in Rails. redirect_ to login_ path, : flash = > { : error = > " My error here" } # or with.