# controller failing to read flash

**URL:** <https://discuss.rubyonrails.org/t/controller-failing-to-read-flash/54073>\
**Category:** rubyonrails-talk\
**Created:** [September 2, 2010, 10:36am UTC](https://discuss.rubyonrails.org/t/controller-failing-to-read-flash/54073 "2010-09-02T10:36:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_C](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@Andrew\_C](https://discuss.rubyonrails.org/u/Andrew_C)\
**Post date:** [September 2, 2010, 10:36am UTC](https://discuss.rubyonrails.org/t/controller-failing-to-read-flash/54073/1 "2010-09-02T10:36:40Z")

</div>

I'm seeing some pretty strange behavior from the flash in my rails 2.3.8 app. I set the flash in a request, and then redirect. In the next request (the one redirected to), accessing the flash returns an empty hash, but the flash is stored and visible in the session.

(rdb:21) session {:user\_credentials=\>"...", :session\_id=\>"...", :user\_credentials\_id=\>1, :flash=\>{:notice=\>"Twitter status updated"}, :\_csrf\_token=\>"..."} (rdb:21) session[:flash] {:notice=\>"Twitter status updated"} (rdb:21) flash {}

Looking at the source for flash in actionpack-2.3.8/lib/ action\_controller/flash.rb, the difference is that the key is stored as a string and not a symbol. How could that disparity occur?

# Access the contents of the flash. Use \<tt\>flash["notice"]\</tt\> to &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# read a notice you put there or \<tt\>flash["notice"] = "hello"\</tt\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# to put a new one. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def flash #:doc: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if !defined?(@\_flash) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@\_flash = session["flash"] || FlashHash.new &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@\_flash.sweep &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@\_flash &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end

Thanks!

Andrew
