问题描述
我正在尝试在 rails 3.2.8 中建立一个简单的基于子域的博客.基本上,它将拥有站点、用户(通过 Devise 进行身份验证)和将用户连接到站点的成员资格.我设置了 POW,以便 myapp.dev 正常工作.每个站点都有一个子域,我可以毫无问题地使用子域导航到 site#show 操作.我的问题是我无法跨子域共享设计会话.我的 heroku 应用程序一切正常,但我希望能够在本地进行测试.
I am trying to set up a simple subdomain-based blog in rails 3.2.8. Basically it will have sites, users (authenticated through Devise), and memberships to connect users to sites. I set up POW so that myapp.dev is working properly. Each site has a subdomain and I can navigate to the site#show action using the subdomains with no problems. My issue is that I can't get the Devise sessions to be shared across subdomains. Everything is working fine on my heroku app, but I would like to be able to test this locally.
当我将以下内容添加到 session_store.rb 时,会话似乎可以跨子域工作,但随后我无法注销.
When I add the following to session_store.rb, teh sessions seem to work across subdomains, but then I can't log out.
Appname::Application.config.session_store :cookie_store, :key => '_appname_session', domain: :all
当我将结尾更改为域:.appname.dev"时,它不起作用.
When I change the end to domain: ".appname.dev" it doesn't work.
任何帮助将不胜感激!
推荐答案
确保清除 cookie 并重新启动应用程序.
Make sure you clear your cookies and restart the app.
Appname::Application.config.session_store :cookie_store, :key => '_appname_session', domain: ".appname.dev"
domain: ".appname.dev"
是域选项的正确格式.起步阶段很重要.
domain: ".appname.dev"
is the correct format for the domain option. The beginning period is important.
这篇关于Rails 3.2.8 - 使用 POW 跨子域共享设计会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!