Adding a directory to the load path in Rails?

后端 未结 8 1039
囚心锁ツ
囚心锁ツ 2020-12-04 14:25

As of Rails 2.3, what\'s the right way to add a directory to the load path so that it hooks into Rails\' auto-reloading mechanisms?

The specific example I\'m thinkin

8条回答
  •  孤城傲影
    2020-12-04 14:33

    In config/application.rb add config.autoload_paths << "#{config.root}/models/widgets".

    File should look like this:

    module MyApp
      class Application < Rails::Application
        config.autoload_paths << "#{config.root}/models/widgets"
      end
    end
    

    I know this works for Rails 4 and 5. Probably others as well.

提交回复
热议问题