0
我的put_flash(conn)
和get_flash(conn)
方法行爲奇怪;當我使用重定向一切工作正常,但沒有顯示出來,當我嘗試在控制器後面添加flash_msg
。鳳凰1.3閃不出現
看起來消息存儲在:phoenix_flash
而不是:plug_session
;有什麼想法嗎?
def index(conn, _params) do
conn
|> put_flash(:info, "Welcome : info")
|> put_flash(:error, "Welcome : error")
render conn, "index.html"
end
private: %{EverlearnWeb.Router => {[], %{}},
:phoenix_action => :index,
:phoenix_controller => EverlearnWeb.PageController,
:phoenix_endpoint => EverlearnWeb.Endpoint,
:phoenix_flash => %{"error" => "Welcome : error", "info" => "Welcome : info"},
:phoenix_layout => {EverlearnWeb.LayoutView, :app},
:phoenix_pipelines => [:browser], :phoenix_router => EverlearnWeb.Router,
:phoenix_view => EverlearnWeb.PageView,
:plug_session => %{"_csrf_token" => "xxx",
"phoenix_flash" => %{"info" => "Welcome back Thibaut, your are signed in !"},
"user_id" => 1}, :plug_session_fetch => :done}
謝謝!我怎麼會錯過它... 只是爲了獲得信息,爲什麼然後它出現在private.phoenix_flash? – Thib
很不幸,很抱歉,我無法評論實施細節... –