As title, I wonder what's the difference between Rails flash.discard
and flash.delete
.
2 Answers
@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
flash.delete
is immediate. flash.discard
will remove the flash at the end of the current action.
So using flash.discard
you can still examine the flash contents in the current action.