LoginSignup
2
2

More than 5 years have passed since last update.

[rails] app下に新しく置いたディレクトリがロードされない時

Posted at

現象

appの下にservicesというディレクトリを置いてもロードされず、NameError: uninitialized constantでクラスが読めません。

環境

  • Ruby 2.3.3
  • Rails 5.0.1

結論

Springを一度停止したところloadされるようになりました。

Before

server git:(master) ➜  bin/rails runner 'puts ActiveSupport::Dependencies.autoload_paths'
Running via Spring preloader in process 54908
/Users/y1row/src/github.com/app/server/app/assets
/Users/y1row/src/github.com/app/server/app/channels
/Users/y1row/src/github.com/app/server/app/controllers
/Users/y1row/src/github.com/app/server/app/controllers/concerns
/Users/y1row/src/github.com/app/server/app/helpers
/Users/y1row/src/github.com/app/server/app/jobs
/Users/y1row/src/github.com/app/server/app/mailers
/Users/y1row/src/github.com/app/server/app/models
/Users/y1row/src/github.com/app/server/app/models/concerns
/Users/y1row/src/github.com/app/server/app/serializers

Spring停止

server git:(master) ➜  bin/spring stop
Spring stopped.

After

server git:(master) ➜  bin/rails runner 'puts ActiveSupport::Dependencies.autoload_paths'
Running via Spring preloader in process 54986
/Users/y1row/src/github.com/app/server/app/assets
/Users/y1row/src/github.com/app/server/app/channels
/Users/y1row/src/github.com/app/server/app/controllers
/Users/y1row/src/github.com/app/server/app/controllers/concerns
/Users/y1row/src/github.com/app/server/app/helpers
/Users/y1row/src/github.com/app/server/app/jobs
/Users/y1row/src/github.com/app/server/app/mailers
/Users/y1row/src/github.com/app/server/app/models
/Users/y1row/src/github.com/app/server/app/models/concerns
/Users/y1row/src/github.com/app/server/app/serializers
/Users/y1row/src/github.com/app/server/app/services ←増えた
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2