phonelib icon indicating copy to clipboard operation
phonelib copied to clipboard

Can we add a "require 'rails/all'" to the initializer?

Open eileen-jiang opened this issue 2 years ago • 2 comments

Related to https://github.com/daddyz/phonelib/pull/288 (cc. @tgwizard).

Request: Can we add a require 'rails/all' to the Phonelib initializer? i.e.

if defined?(Rails)
    require 'rails/all' # <-- added
    class Phonelib::Railtie < Rails::Railtie

Happy to make this change myself, but wanted to see if there's a faster workaround.

Context: I'm having trouble starting up the multi-process feature of Sidekiq Enterprise. More details on the issue here.

At least Rails::Railtie and Rails::Engine are undefined.

Adding gem 'phonelib', require: 'rails/all' to my Gemfile does not work.

> bundle exec sidekiqswarm
[swarm] Preloading Bundler groups ["default"]
/Users/eileenj/.rvm/gems/ruby-3.1.4/gems/phonelib-0.8.7/lib/phonelib.rb:22:in `<top (required)>': uninitialized constant Rails::Railtie (NameError)

    class Phonelib::Railtie < Rails::Railtie
                                   ^^^^^^^^^

eileen-jiang avatar Feb 26 '24 21:02 eileen-jiang

@eileen-jiang did you try to use approach described in https://github.com/sidekiq/sidekiq/issues/4766#issuecomment-930861731 and https://github.com/sidekiq/sidekiq/issues/4766#issuecomment-1013400982

daddyz avatar Mar 16 '24 17:03 daddyz