Domanda

After reading this, I found that there isn't much of a difference between error, notice, and alert and that you can put whatever you want in the flash.

However, I noticed that there seem to be built-in methods for getting the notices and alerts from the flash in views, but no built-in method for retrieving error messages.

I was wondering why this is the case. Is the use of error in the flash discouraged?

È stato utile?

Soluzione

No, using flash for errors is certainly not discouraged and in fact part of the official documentation.

You are seeing accessors and built-in methods for alert and notices simply because they are the most common ones. As you might have seen in the linked questions, flash is just a hash and you can use any key that fits your application well. I believe common practice, at least from my experience, is that :notice is for messages that report a correctly completed task, :alert for non-showstopper errors, and :error for showstopper errors.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top