从' rails',' 2.3.15'升级后,我收到以下错误to' rails',' 3.2.17'
Processing by HomeController#index as HTML
Completed 500 Internal Server Error in 320.9ms
SystemStackError (stack level too deep):
.bundle/ruby/1.9.1/gems/actionpack-3.2.17/lib/action_dispatch/middleware/reloader.rb:70
我知道错误在以下方法中:
def current_user
return @current_user if defined?(@current_user)
@current_user = current_user_session && current_user_session.record
Authorization.current_user = @current_user
end
如果使用rails 3实现authlogic的人可以给我一些提示,那会很棒。
非常感谢!
这是我的完整应用程序控制器:
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
helper_method :current_user_session, :current_user
helper_method :current_user
helper_method :current_division
rescue_from Authorization::AttributeAuthorizationError, :with => :rescue_auth_error
protect_from_forgery # See ActionController::RequestForgeryProtection for details
# Scrub sensitive parameters from your log
around_filter :clear_current_user
before_filter :require_user
before_filter :configure_mailers
private
def rescue_auth_error(exception)
if current_user.present?
UserSession.find(current_user.id).destroy
flash[:error] = "Your session has expired. Please log in again."
redirect_to root_url
end
end
def clear_current_user
remove_instance_variable :@current_user if defined?(@current_user)
remove_instance_variable :@current_user_session if defined?(@current_user_session)
yield
remove_instance_variable :@current_user if defined?(@current_user)
remove_instance_variable :@current_user_session if defined?(@current_user_session)
Authorization.current_user = nil
end
def current_user_session
return @current_user_session if defined?(@current_user_session) && !@current_user_session.nil?
@current_user_session = UserSession.find
# @current_user_session = current_division.user_sessions.find
end
def current_user
return @current_user if defined?(@current_user)
@current_user = current_user_session && current_user_session.record
Authorization.current_user = @current_user
end
def require_user
unless current_user
store_location
# flash[:notice] = "You must be logged in to access this page"
redirect_to new_user_session_url
return false
end
end
def require_no_user
if current_user
store_location
# flash[:notice] = "You must be logged out to access this page"
redirect_to account_url
return false
end
end
def store_location
session[:return_to] = request.request_uri
end
def redirect_back_or_default(default)
redirect_to(session[:return_to] || default)
session[:return_to] = nil
end
def current_division
@current_division ||= Division.find_by_code('prd')
end
def configure_mailers
Notifier.configure(request)
end
def permission_denied
flash[:error] = "You do not have permission to access that page."
redirect_to root_url
end
end
答案 0 :(得分:0)
此宝石导致错误:
gem 'rd_searchlogic', :require => 'searchlogic', :git => 'git://github.com/railsdog/searchlogic.git'
替换为:
gem 'ransack'
现在一切都很好。