Skip to content

I want to set config.require_tenant to false when the path is /admin, but it doesn't work. #299

@hatsu38

Description

@hatsu38

I am using ActsAsTenant.
Recently, I wanted to change require_tenant dynamically because I plan to create an admin page.
So I looked at the README and rewrote acts_as_tenant.rb using lambda.

cat config/initializers/acts_as_tenant.rb

ActsAsTenant.configure do |config|
  config.require_tenant = lambda do
    puts "*" * 30
    p $request
    p $request_env
    puts "*" * 30
    if $request_env.present?
      return false if $request_env["REQUEST_PATH"].start_with?("/admin/")
    end
    true
  end
end

But $request_env is always nil even though the controller is working, so $request_env.present? is still false

******************************
nil
nil
******************************

Is there any way to set require_tenant to false only for the /admin path?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions