我照常创建了一条记录,并且byebug确认已创建Flash消息。但是,当我被重定向时,我根本看不到任何闪烁。闪存在某些情况下会被删除吗?我该如何解决?我使用定制的omniauth授权方法。如果这引起了问题,我该如何进一步调查?
[262, 271] in /home/jacekp/.rvm/gems/ruby-2.4.5@rails4qc_charts/gems/actionpack-4.2.10/lib/action_dispatch/middleware/flash.rb
262: session = Request::Session.find(env) || {}
263: flash_hash = env[KEY]
264:
265: if flash_hash && (flash_hash.present? || session.key?('flash'))
266: session["flash"] = flash_hash.to_session_value
=> 267: env[KEY] = flash_hash.dup
268: end
269:
270: if (!session.respond_to?(:loaded?) || session.loaded?) && # (reset_session uses {}, which doesn't implement #loaded?)
271: session.key?('flash') && session['flash'].nil?
(byebug) session["flash"]
{"discard"=>[], "flashes"=>{"notice"=>"Sample was successfully created."}}
(byebug) n
[266, 275] in /home/jacekp/.rvm/gems/ruby-2.4.5@rails4qc_charts/gems/actionpack-4.2.10/lib/action_dispatch/middleware/flash.rb
266: session["flash"] = flash_hash.to_session_value
267: env[KEY] = flash_hash.dup
268: end
269:
270: if (!session.respond_to?(:loaded?) || session.loaded?) && # (reset_session uses {}, which doesn't implement #loaded?)
=> 271: session.key?('flash') && session['flash'].nil?
272: session.delete('flash')
273: end
274: end
275: end
我已在.rvm / gems / ruby-2.4.5 @ rails4qc_charts / gems / rack-1.6.11 / lib / rack / request.rb中插入byebug
def session; byebug ; @env['rack.session'] ||= {} end
查看正在发生的事情,并尝试了一个在会话中设置Flash的页面。 我正在用
进行检查(byebug)@env ['rack.session']。keys
没有找到任何可以给我线索的东西。
答案 0 :(得分:0)
经过数小时的调试,我有了一个更好的主意,可以用Google搜索什么,并找到了这篇文章: Rails flash missing from session
所以我已经注释掉了我的错误 config / application.rb
config.middleware.use ActionDispatch::Cookies # Required for all session management
#config.middleware.use ActionDispatch::Session::CookieStore, config.session_options
在注释第二行之前,我遇到了消失的Flash错误。