当我尝试登录我的Rails应用程序时,我在日志中收到以下错误:
I, [2016-10-03T11:44:17.136518 #13441] INFO -- : Started GET "/" for 72.238.233.104 at 2016-10-03 11:44:17 -0500
I, [2016-10-03T11:44:17.139196 #13441] INFO -- : Processing by PagesController#home as HTML
I, [2016-10-03T11:44:17.144634 #13441] INFO -- : Redirected to https://www.myserver.org/admin/
I, [2016-10-03T11:44:17.144741 #13441] INFO -- : Filter chain halted as :redirect_admin rendered or redirected
I, [2016-10-03T11:44:17.144949 #13441] INFO -- : Completed 302 Found in 6ms (ActiveRecord: 1.8ms)
I, [2016-10-03T11:44:17.394535 #13441] INFO -- : Started GET "/admin/" for 72.238.233.104 at 2016-10-03 11:44:17 -0500
I, [2016-10-03T11:44:17.396819 #13441] INFO -- : Processing by RailsAdmin::MainController#dashboard as HTML
I, [2016-10-03T11:44:17.402503 #13441] INFO -- : Redirected to https://www.myserver.org/
I, [2016-10-03T11:44:17.402686 #13441] INFO -- : Completed 302 Found in 6ms (ActiveRecord: 1.6ms)
I, [2016-10-03T11:44:17.650009 #13477] INFO -- : Started GET "/" for 72.238.233.104 at 2016-10-03 11:44:17 -0500
I, [2016-10-03T11:44:17.651967 #13477] INFO -- : Processing by PagesController#home as HTML
I, [2016-10-03T11:44:17.657941 #13477] INFO -- : Redirected to https://www.myserver.org/admin/
I, [2016-10-03T11:44:17.658051 #13477] INFO -- : Filter chain halted as :redirect_admin rendered or redirected
I, [2016-10-03T11:44:17.658498 #13477] INFO -- : Completed 302 Found in 6ms (ActiveRecord: 1.8ms)
I, [2016-10-03T11:44:17.909178 #13483] INFO -- : Started GET "/admin/" for 72.238.233.104 at 2016-10-03 11:44:17 -0500
I, [2016-10-03T11:44:17.911936 #13483] INFO -- : Processing by RailsAdmin::MainController#dashboard as HTML
I, [2016-10-03T11:44:17.917690 #13483] INFO -- : Redirected to https://www.myserver.org/
I, [2016-10-03T11:44:17.917845 #13483] INFO -- : Completed 302 Found in 6ms (ActiveRecord: 1.9ms)
在浏览器窗口中我得到:
The www.myserver.com page isn’t working
www.myserver.com redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS
我从哪里开始排查?
我使用Rails_Admin gem进行管理,设计用于身份验证
谢谢!
更新 这是我的注册控制器:
class Users::RegistrationsController < Devise::RegistrationsController
before_action :get_company_and_locations, only: [:edit, :update]
def edit
@card = get_stripe_info_by_customer(current_user.company.stripe_id)
@last4 = @card.last4
@exp_month = @card.exp_month
@exp_year = @card.exp_year
end
# PUT /resource
def update
@user = User.find(current_user.id)
if @user.update_with_password(user_params)
sign_in @user, :bypass => true
redirect_to :back
flash[:success] = "Your profile has been updated successfully!"
else
redirect_to :back
end
end
private
def user_params
# NOTE: Using `strong_parameters` gem
params.require(:user).permit(:email, :first_name, :last_name, :phone_number, :password, :password_confirmation, :current_password, :enable_notifications, :time_zone, :avatar)
end
def sign_up_params
params.require(:user).permit(:email, :first_name, :last_name, :phone_number, :password, :password_confirmation, :enable_notifications, :time_zone)
end
def account_update_params
params.require(:user).permit(:email, :first_name, :last_name, :phone_number, :password, :password_confirmation, :current_password, :enable_notifications, :time_zone)
end
def after_inactive_sign_up_path_for(resource)
new_user_session_path
end
end
更新
它看起来像管理员登录的控制器在application_controller
中,因此,这里是文件:
class ApplicationController < ActionController::Base
include ApplicationHelper
protect_from_forgery with: :null_session, if: ->(controller) { controller.request.format == "application/json" }
before_filter :configure_permitted_parameters, if: :devise_controller?
before_action :authenticate_user_from_token!
before_action :authenticate_user!
before_action :redirect_admin
around_action :set_time_zone
layout :layout_by_resource
private
def redirect_admin
if current_user && current_user.admin? && !rails_admin_controller? && !devise_controller?
redirect_to rails_admin.dashboard_path
end
end
我认为:redirect_admin
是我的问题,因为这是日志中提到的内容,但我不明白为什么......
答案 0 :(得分:0)