Adding a directory to the load path in Rails?

后端 未结 8 1016
囚心锁ツ
囚心锁ツ 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:45

    For older versions of Rails:

    You can do this in your environment.rb config file.

    config.load_paths << "#{RAILS_ROOT}/app/widgets"
    

    --

    For Rails 3, see answers bellow

    0 讨论(0)
  • 2020-12-04 14:45

    Another update for rails 3 -- activesupport 3.0.0:

    Instead of:

    ActiveSupport::Dependencies.load_paths << "#{RAILS_ROOT}/app/widgets"
    

    You may need to do this:

    ActiveSupport::Dependencies.autoload_paths << "#{RAILS_ROOT}/app/widgets"
    
    0 讨论(0)
提交回复
热议问题