Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from subdomains to generic elevator #652

Open
mfts opened this issue Jun 8, 2020 · 1 comment
Open

Switch from subdomains to generic elevator #652

mfts opened this issue Jun 8, 2020 · 1 comment

Comments

@mfts
Copy link

mfts commented Jun 8, 2020

I have set up an application with tenants based on subdomain. Here I used the subdomain elevators and subdomain middleware as instructed.

Now, I would like to change the way Apartment finds the database schema to a different variable because I would like to let my users change their subdomain.

Steps to reproduce

## apartment.rb

require 'apartment/elevators/generic'

Apartment.configure do |config|

  config.excluded_models = %w{ Tenant }

  config.tenant_names = lambda { Tenant.pluck :uuid }

  config.seed_after_create = true
end

Rails.application.config.middleware.use "Apartment::Elevators::Generic", lambda { |request|
  Tenant.find_by(subdomain: request.subdomains.first).uuid
}

Expected behavior

Apartment finds database by uuids

Actual behavior

Error with the following message

undefined method `new' for "Apartment::Elevators::Generic":String (NoMethodError)

I understand that I should somehow change the schema names initially to the uuids but still there seems to be something wrong.

System configuration

  • Database: (Tell us what database and its version you use.)
    psql (PostgreSQL) 12.3

  • Apartment version:
    apartment (2.2.1)

  • Apartment config (in config/initializers/apartment.rb or so):
    see above

    • use_schemas: true
  • Rails (or ActiveRecord) version:
    rails (5.2.4.3)

  • Ruby version:
    ruby (2.6.5)

@mfts
Copy link
Author

mfts commented Jun 8, 2020

Referncing another issue #242 because I think they're related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant