无法在Rails 3.0.1上使用Authlogic设置current_user

我在Rails 2.3.5上运行了官方的authlogic插件。 我将我的应用程序转换为Rails 3.0.1,现在我遇到了一些问题。

我在我的gemfile gem’authlogic gem 'authlogic', :git => 'git://github.com/odorcicd/authlogic.git', :branch => 'rails3'包含了以下authlogic gem gem 'authlogic', :git => 'git://github.com/odorcicd/authlogic.git', :branch => 'rails3' ,: gem 'authlogic', :git => 'git://github.com/odorcicd/authlogic.git', :branch => 'rails3'

用户登录时会保存会话。 调用该用户会话时,返回的值为nil。 UserSession.find returns a nil value因此我无法分配current_user。

sessions_controller.rb

  def create @user_session = UserSession.new(params[:user_session]) if @user_session.save! flash[:notice] = 'Login successful' redirect_to root_url else render :action => 'new' end end 

application_controller.rb

  helper_method :current_user, :current_user_session private def current_user_session return @current_user_session if defined?(@current_user_session) @current_user_session = UserSession.find end def current_user return @current_user if defined?(@current_user) @current_user = current_user_session && current_user_session.record end 

当用户登录时,闪回通知返回'Login sucessful'但未设置current_user。 我也尝试使用官方的authlogic插件,没有任何改变。 我在这里错过了什么吗?

谢谢!

蒂姆

我遇到了这个问题。 由于某种原因,它干扰了基本身份validation – 修复它我将allow_http_basic_auth设置为false。

 class UserSession < Authlogic::Session::Base allow_http_basic_auth false end