未设置Rails 4会话cookie [英] Rails 4 sessions cookie is not set

查看:79
本文介绍了未设置Rails 4会话cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建Rails 4应用程序。它主要是json api,因此我还在我的应用中使用了 rails-api gem。我有ApiControllers扩展了 ActionController :: API

I'm building Rails 4 application. It's mostly json api so I'm also using rails-api gem in my app. I have ApiControllers which extends ActionController::API.

现在我需要添加一些经典的服务器渲染HTML模板。这些渲染器的控制器扩展了 ActionController :: Base

Now I need to add some classic server render HTML templates. Controllers for those renders extends ActionController::Base.

我有问题,滑轨没有在浏览器中设置cookie,所以我的会话没有都在工作。我试图在其中启动新的Rails 4应用程序和会话,并且一切正常。我不知道为什么它在我的应用程序中不起作用。 set-cookie标头丢失。有想法吗?

I have problem, that rails are not setting cookie in browser, so my sessions are not working at all. I tried to start new Rails 4 app and sessions in it and everything works fine. I don't know why it is not working in my application. set-cookie header is missing. Any ideas?

推荐答案

知道了!


rails-api 更改一些应用程序配置。我必须在 config / application.rb

Got it!

rails-api change some application configuration. I have to add this code in config/application.rb

config.api_only = false

此线程的THX:
将cookie会话存储添加回Rails API应用

这篇关于未设置Rails 4会话cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆