How can I add a services directory to the load path in Rails?
First of all, the code under app
folder will be loaded without any config.
I think the problem was the folder structure doesn't match with your class definition.
So this config will work:
app/services/foo/test.rb
module Foo
class Test
end
end
My clue is, for example we have app/controllers/api/v1/users_controllers.rb
and the class constant will be Api::V1::UsersController
, not Controllers::Api::V1::UsersController
Update
Conventionally, we usually use FooServices
instead of Foo
, it is clearer, for example:
app/services/foo_services/bar_parser.rb
module FooServices
class BarParser
# Do stuff
end
end
So we understand that every class inside foo_services
folder is a service which related to Foo
After add new dir, reload spring
spring stop