Adding a directory to the load path in Rails?

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

    In Rails 5 you don't have to explicitly load folders from within the app directory anymore. All folders placed inside are directly available. You don't have to touch any of the config files. But it seems as if there are some issues with Spring.

    The new workflow therefore is:

    1. create a new folder and class inside the /app directory
    2. run spring stop on the command line
    3. check the autoload-paths with bin/rails r 'puts ActiveSupport::Dependencies.autoload_paths' on the command line. The new folder should now be listed.
    4. run spring start on the command line

提交回复
热议问题