Ruby on rails 使用mongo_session_store-rails3,session不会';好像不行

Ruby on rails 使用mongo_session_store-rails3,session不会';好像不行,ruby-on-rails,session,mongodb,mongoid,ruby-on-rails-3.2,Ruby On Rails,Session,Mongodb,Mongoid,Ruby On Rails 3.2,当我使用mongoid作为SessionStore时,rails 3.2中的会话有问题。我决定使用mongo_session_storegem的fork,因为它是上个月更新的 在切换到这个gem之前,我使用的是默认的基于cookie的会话存储,它可以正常工作。但是现在,当我重定向到另一个页面时,即使是flash也不起作用。会话数据似乎在每次请求时都会重置 还有一个附带问题:每个请求都会在db中创建一个新的会话文档!是这样吗?我很困惑=( 我将这些行放在我的文件中: gem 'mongoid',

当我使用mongoid作为SessionStore时,rails 3.2中的会话有问题。我决定使用
mongo_session_store
gem的fork,因为它是上个月更新的

在切换到这个gem之前,我使用的是默认的基于cookie的会话存储,它可以正常工作。但是现在,当我重定向到另一个页面时,即使是
flash
也不起作用。会话数据似乎在每次请求时都会重置

还有一个附带问题:每个请求都会在db中创建一个新的会话文档!是这样吗?我很困惑=(

我将这些行放在我的文件中:

gem 'mongoid', :git => 'git://github.com/mongoid/mongoid.git'
gem 'bson_ext', "~> 1.5"
gem 'mongo_session_store-rails3', '~> 3.0.5'
然后在my
config/initializers/session\u store.rb中:

SomeAppName::Application.config.session_store :mongoid_store
会话\u controller.rb:

class SessionsController < ApplicationController
  def new
    ...
  end
  def create
    user = User.find_by_identifier(params[:identifier])
    if user && user.authenticate(params[:password])
      session[:uid] = user._id
      redirect_to root_url, :notice => "Logged in!"
    else
      flash.now.alert = "Invalid email or password"
      render :new
    end
  end
  def destroy
    ...
  end
end
 <class:Session>': undefined method `collection_name=' for ActionDispatch::Session::MongoidStore::Session:Class (NoMethodError)
class sessioncontroller“已登录!”
其他的
flash.now.alert=“无效的电子邮件或密码”
渲染:新
结束
结束
def销毁
...
结束
结束

如果需要我的代码的任何其他部分,请告诉我将其发布。提前感谢。

我的项目中存在类似和其他问题。 按预期变更为所有工程的分公司后

分支机构说明:

此分叉旨在解决我与master branch之间的几个问题:

class SessionsController < ApplicationController
  def new
    ...
  end
  def create
    user = User.find_by_identifier(params[:identifier])
    if user && user.authenticate(params[:password])
      session[:uid] = user._id
      redirect_to root_url, :notice => "Logged in!"
    else
      flash.now.alert = "Invalid email or password"
      render :new
    end
  end
  def destroy
    ...
  end
end
 <class:Session>': undefined method `collection_name=' for ActionDispatch::Session::MongoidStore::Session:Class (NoMethodError)
”:ActionDispatch::Session::MongoidStore::Session:Class(NoMethodError)的未定义方法“collection\u name=”

”:未初始化的常量ActionDispatch::Session::MongoidStore::Session::BSON(NameError)

在我的项目中有类似的问题和其他问题。 按预期变更为所有工程的分公司后

分支机构说明:

此分叉旨在解决我与master branch之间的几个问题:

class SessionsController < ApplicationController
  def new
    ...
  end
  def create
    user = User.find_by_identifier(params[:identifier])
    if user && user.authenticate(params[:password])
      session[:uid] = user._id
      redirect_to root_url, :notice => "Logged in!"
    else
      flash.now.alert = "Invalid email or password"
      render :new
    end
  end
  def destroy
    ...
  end
end
 <class:Session>': undefined method `collection_name=' for ActionDispatch::Session::MongoidStore::Session:Class (NoMethodError)
”:ActionDispatch::Session::MongoidStore::Session:Class(NoMethodError)的未定义方法“collection\u name=”

”:未初始化的常量ActionDispatch::Session::MongoidStore::Session::BSON(NameError)

这里是Gem作者。4.0.0版刚刚发布,支持Mongoid 3

gem 'mongo_session_store-rails3', '~> 4.0.0'

Gem作者在这里。4.0.0版刚刚发布,支持Mongoid 3

gem 'mongo_session_store-rails3', '~> 4.0.0'

你检查过你的数据库会话文档是否保存了吗?是的。正如我所说的,
sessions
集合在那里,对于每个请求,都会在其中创建一个新的
session
文档。你检查过你的数据库会话文档是否保存了吗?是的。正如我所说的,
sessions
集合在那里,并且或者每个请求都会在其中创建一个新的
会话
文档。