def index
redirect_to new_post_url, flash: flash
end
NoMethodError:
undefined method `stringify_keys' for #<ActionDispatch::Flash::FlashHash:0x00000006dd96f8>
flash is an instance of ActionDispatch::Flash::FlashHash
. This code was weird
but worked in versions before 4.1.0 because nothing was done to the FlashHash:
In 4.1.0 they're now stringifying the keys: https://github.com/rails/rails/commit/a668beffd64106a1e1fedb71cc25eaaa11baf0c1
ActionDispatch::Flash::FlashHash
doesn't have a #stringify_keys
method.
You only pass a flash if you actually want to pass a message around, as a string or hash:
def index
redirect_to new_post_url, flash: "Some message"
end