Rails: uninitialized constant just happen on production server

后端 未结 1 1771
甜味超标
甜味超标 2021-01-18 07:28

I have a class that I put inside lib/network:

module NetworkApi
  class NetworkProxy
  end
end

Then in another class, I refere

1条回答
  •  后悔当初
    2021-01-18 08:12

    Note that Rails 5 disables autoloading after booting the app in production.

    From the linked blog post:

    In the rare situation where our application still needs autoloading in the production environment, we can enable it by setting up enable_dependency_loading to true as follows:

    # config/application.rb 
    
    config.enable_dependency_loading = true
    config.autoload_paths << Rails.root.join('lib')`
    

    0 讨论(0)
提交回复
热议问题