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

Trying to switch on tld #276

Closed
enyachoke opened this issue Nov 10, 2015 · 3 comments
Closed

Trying to switch on tld #276

enyachoke opened this issue Nov 10, 2015 · 3 comments

Comments

@enyachoke
Copy link

The gem is trying to switch based on the tld and am using the subdomain elevetor
http://savannahacademia.co.ke/

Apartment::TenantNotFound (One of the following schema(s) is invalid: "savannahacademia" "public"):
18:08:07 web.1 | vendor/bundle/ruby/2.0.0/gems/apartment-1.0.2/lib/apartment/adapters/postgresql_adapter.rb:92:in rescue in connect_to_new' 18:08:07 web.1 | vendor/bundle/ruby/2.0.0/gems/apartment-1.0.2/lib/apartment/adapters/postgresql_adapter.rb:85:inconnect_to_new'
18:08:07 web.1 | vendor/bundle/ruby/2.0.0/gems/apartment-1.0.2/lib/apartment/adapters/abstract_adapter.rb:84:in switch!' 18:08:07 web.1 | vendor/bundle/ruby/2.0.0/gems/apartment-1.0.2/lib/apartment/elevators/generic.rb:21:incall'
18:08:07 web.1 | vendor/bundle/ruby/2.0.0/gems/pdfkit-0.6.2/lib/pdfkit/middleware.rb:17:in call' 18:08:07 web.1 | vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:35:inblock in call'
18:08:07 web.1 | vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in catch' 18:08:07 web.1 | vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:incall'
18:08:07 web.1 | vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/etag.rb:24:in call' 18:08:07 web.1 | vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/conditionalget.rb:25:incall'

@mikecmpbll
Copy link
Collaborator

The default tld_length is 1, you should set this in your Apartment config initializer (config/initializers/apartment.rb):

#
# Apartment Configuration
#
Apartment.configure do |config|
  # ...
  config.tld_length = 2
  # ...
end

@enyachoke
Copy link
Author

Thanks closing I had to set

#......
  class Application < Rails::Application
#......
config.action_dispatch.tld_length = 2
#......
end
#........

too.

@choznerol
Copy link

choznerol commented Jun 20, 2020

For people arrived this thread years later:

Apartment's owntld_length configuration option seemed to be deprecated since #309 and will have no effect.

If both http://savannahacademia.co.ke/ and http://tenant-name.savannahacademia.co.ke/ are valid in your app, configure the default elevator like below to avoid Apartment::TenantNotFound (One of the following schema(s) is invalid: "savannahacademia" "public") in http://savannahacademia.co.ke/:

# config/initializers/apartment.rb
...
elevator = Apartment::Elevators::Subdomain
elevator.excluded_subdomains = ['savannahacademia']
Rails.application.config.middleware.insert_before Warden::Manager, elevator

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

3 participants