Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: redirect_to with :error, but flash[:error] empty

As stated in the Rails API only :notice and :alert are by default applied as a flash hash value. If you need to set the :error value, you can do it like this:

redirect_to show_path, flash: { error: "Insufficient rights!" }

If you are having problem to keep the flash after redirecting to another path, then use this.

flash.keep

in your method, before redirecting.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!