ruby-on-rails - 闪光[:notice] not working when redirect_to changes from http to https and vice versa

标签 ruby-on-rails ssl https

当用户登录系统时,是在https

然后进入首页,是http

在登录期间,根据特定条件,我们使用 flash[:notice] 向用户发送一些消息

但是 flash[:notice] 不工作。

ssl 未实现时,flash[:notice] 工作正常。

redirectionhttphttp 页面也 flash[:notice] 完美工作。

我们也实现了

flash.keep

redirect_to path_to_path, :flash=>{:notice=>"our message"}

但是他们都失败了。

有没有人遇到过这种情况,请指点。

最佳答案

flash 消息是使用服务器 session 实现的。但是,根据服务器和配置, session 不会在 http 和 https session 之间共享。换句话说,如果您从 http 切换到 https,反之亦然,服务器会创建两个不同的用户 session 。

您可以通过打印 session ID 并比较它是否相同来检查这一点。

您可以通过在表示消息的查询字符串中传递参数(例如 redirect_to path_to_path(message: 1))来解决此问题,然后在操作检查中(如果该参数存在) , 在 View 中打印出消息(将在 View 中编码)。

关于ruby-on-rails - 闪光[:notice] not working when redirect_to changes from http to https and vice versa,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21021285/

相关文章:

ruby-on-rails - rails : How to group records that have the same Date (month day year) for a Datetime field?

ruby-on-rails - ruby rails 4.2.0 : How to find the directories set for loading libraries etc

java ssl : chrome/firefox sends "G" in http header instead of "GET/HTTP/1.1"

http - 如何在 anchor 中指定协议(protocol)并仍然使用相对路径?

未找到证书路径的 Android Volley 自签名 HTTPS 信任 anchor

PHP - Symfony2 功能测试 HTTPS 路由

ruby-on-rails - AngularJS错误: [$injector:nomod] when trying to load 'templates'

ruby-on-rails - Psych::SyntaxError无法解析YAML

python - Hashicorp python 客户端 hvac 问题 :- "bad handshake: Error([(' SSL routines', 'tls_process_server_certificate' 、 'certificate verify failed'

ssl - Hashicorp Vault tls cert 认证不读取证书