在index
頁MyController
我的值設置爲flash[:notice]
:Rails:當「flash」散列變爲空時?
class MyController < ApplicationController
def index
flash[:notice] = "my message"
...
end
end
我確實看到"my message"
按預期顯示。
然而,當我點擊這個頁面指向index
頁MyOtherController
上的鏈接,我仍然看到"my message"
:
class MyOtherController < ApplicationController
def index
puts "----------------------------------------"
puts flash[:notice] # => "my message"
puts "----------------------------------------"
end
end
我認爲flash[:notice]
變空每個請求,但在這裏,這不是案件。什麼是清空flash[:notice]
的正確方法?
所以,當我只使用`flash [:notice]`時,它什麼時候變空了?有時它變得空虛,有時不變。你能詳細解釋一下嗎? – 2011-02-01 10:18:11