Search code examples
ruby-on-railsflash-message

Rails - `flash.discard` vs `flash.delete`


As title, I wonder what's the difference between Rails flash.discard and flash.delete.


Solution

  • @SteveTurczyn is right.

    However, flash.delete is only possible to do in versions of rails previous to 3.1.

    As of 3.1, flash.delete doesn't work anymore, an alternative might be flash.clear (check out flash.delete(:notice) not working in Rails 3.1 RC?).

    You might also want to check: https://apidock.com/rails/v3.0.0/ActionDispatch/Flash/FlashHash/discard