rails-on-services / apartment

Database multi-tenancy for Rack (and Rails) applications
376 stars 150 forks source link

Code reference to `config.tld_length` generates "NameError: uninitialized constant Apartment::Deprecation" #218

Closed mahendrapk closed 5 days ago

mahendrapk commented 1 year ago

Thanks a lot to contributors for bringing this gem back to life. 🙏

Background

Trying to migrate an existing RoR project that uses influitive/apartment to rails-on-service/apartment

config/initializers/apartment.rb in the existing project had config.tld_length = 1. After switching to ros-apartment the config block started throwing the NameError mentioned in the title.

Steps to reproduce

Apartment.configure do |config|
  //... other settings
  config.tld_length = 1
end

The block throws NameError.

Also when tried in rails console:

image

Expected behavior

Should not throw NameError.

Actual behavior

Throws NameError

System configuration

mahendrapk commented 1 year ago

I did some investigation and found out that #72 deprecated the tld_length and introduced below warning:

  Apartment::Deprecation.warn('`config.tld_length` have no effect because it was removed in https://github.com/influitive/apartment/pull/309')

should that also have require 'apartment/deprecation' ?

mahendrapk commented 1 year ago

For my purpose - I will get rid of tld_length references from the code base as below PRs suggest it has no impact. But feels nice to fix if we can, if all it takes is require.

Ref: