Why doesn't Rails autoload classes from app/services? -


i'm working on rails 4.2 app , have added app/services/fetch_artists.rb structure. inside file, have defined class fetchartists; end.

when trying run rails r 'fetchartists' gives me nameerror: uninitialized constant fetchartists.

i've tried looking @ activesupport::dependencies.autoload_paths , indeed, app/services not there:

/.../app/assets /.../app/controllers /.../app/helpers /.../app/jobs /.../app/mailers /.../app/models /.../app/controllers/concerns /.../app/models/concerns /.../spec/mailers/previews 

my question is, why isn't folder automatically loaded, , should be?

edit

very strange, after repeatedly running above command rails runner, new folder appears on autoload paths. have no idea why happened such lag.

someone suggested may deal spring. hear more on this, since can possibly many others in situation too.

i encountered same problem , seems caching issue spring, process handles preloading app. it's used web server console , rake tasks.

stopping spring bin/spring stop force spring load app fresh. running rails console , inspecting activesupport::dependencies.autoload_paths show app/services.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -