Ruby on rails 登录后ActiveAdmin重定向不';行不通

Ruby on rails 登录后ActiveAdmin重定向不';行不通,ruby-on-rails,devise,activeadmin,Ruby On Rails,Devise,Activeadmin,出于某些原因,ActiveAdmin在成功登录后返回相同的登录页面: 我认为它与“坎坎坎”或“扮演租户”有关,所以我试图删除它,但没有帮助 我没有在/initializers/active_admin.rb中添加任何特殊内容,并且几乎尝试了所有方法 也许有人以前也有过同样的问题 ApplicationController.rb class ApplicationController < ActionController::Base protect_from_forgery with:

出于某些原因,ActiveAdmin在成功登录后返回相同的登录页面:

我认为它与“坎坎坎”或“扮演租户”有关,所以我试图删除它,但没有帮助

我没有在/initializers/active_admin.rb中添加任何特殊内容,并且几乎尝试了所有方法

也许有人以前也有过同样的问题

ApplicationController.rb

class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
  set_current_tenant_through_filter
  before_action :authenticate_admin_user!
  before_action :find_current_tenant, if: -> { current_admin_user }

  def find_current_tenant
    current_account = current_admin_user.business
    set_current_tenant(current_account)
  end
end

我的一些AdminUser,比如“superadmins”,没有“business\u id”(设置为NULL)。这就是问题所在,但在我的例子中,我确实需要为一些用户设置NULL

所以解决方案是这样的

前代码:

class AdminUser < ApplicationRecord
  belongs_to :business
  validates :business, presence: true

  acts_as_tenant(:business)
end
class AdminUser
修复后:

class AdminUser < ApplicationRecord
  belongs_to :business, optional: true

  # for some reasons it's not working without "on: :create", not sure why
  validates :business, presence: true, on: :create

  acts_as_tenant(:business, optional: true)
end
class AdminUser

希望它能帮助别人。

我的一些管理员用户,如“超级管理员”没有“业务id”(设置为空)。这就是问题所在,但在我的例子中,我确实需要为一些用户设置NULL

所以解决方案是这样的

前代码:

class AdminUser < ApplicationRecord
  belongs_to :business
  validates :business, presence: true

  acts_as_tenant(:business)
end
class AdminUser
修复后:

class AdminUser < ApplicationRecord
  belongs_to :business, optional: true

  # for some reasons it's not working without "on: :create", not sure why
  validates :business, presence: true, on: :create

  acts_as_tenant(:business, optional: true)
end
class AdminUser

希望它能帮助别人。

您能附上开发日志中的最后几行吗?它们应该在
logs/development.log
@GregoryWitek添加了您尝试过这个吗?@KrupaSuthar是的,“在路径中签名”没有帮助您可以附加开发日志中的最后几行吗?他们应该在
logs/development.log
@GregoryWitek补充说你试过这个吗?@KrupaSuthar是的,“在路径中签名后”没有帮助