ruby-1.9.3-p194
Rails 3.0.9
I encountered so much strange behavior of flash variable.
My controller
class AdviceController < ApplicationController
# POST /advice/save.js
def save
t = Logger.new(STDOUT)
t.debug '+============================================'
t.debug flash['advice-saving-error-msg']
t.debug '+============================================'
flash['advice-saving-error-msg'] = 'strange string'
t.debug '============================================'
t.debug flash['advice-saving-error-msg']
t.debug '============================================'
end
end
When I ask save action first time I see in debug:
+============================================
nil
+============================================
============================================
strange string
============================================
When I ask save action next time I see in debug!!!!!!!!!!!!:
+============================================
strange string
+============================================
============================================
strange string
============================================
It makes me crazy! Why!!!
I expect to get:
+============================================
nil
+============================================
============================================
strange string
============================================
It looks like Rails saves flash variable through action call.
Could Anyone help me?
Use
Flash.now. Basic flash saves it for the next action.