What is the difference when using flash :error, :alert, and :notice?

flash is a Rails mechanism to persist some information across 2 requests. You set something in flash hash in one request and it’s available in the very next request you receive from that same client.

Since flash is just a “hash” you can use it like one. Which means you can provide your preferred key (:alert/:error/:notice) and put whatever message string you wish as the value.

The semantics of what or when to use :alert/:error/:notice are really up to you to manage. Having said that, the general best practice is to use :notice when things are OKAY and is displayed in a greenish hue, and use :error when things are NOT OKAY and is displayed in a reddish hue. It is completely okay if you want to use :alert for another type of message on your web app. I’ve used it before for informational purposes in a yellowish hue.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)