X
X
xxx44yyy2019-07-23 20:44:51
Ruby on Rails
xxx44yyy, 2019-07-23 20:44:51

Why do you have to restart the server when changing the code in the lib?

I have my own code inside lib/math/paper/fetcher.rb . Development in RubyMine . Enabled development mode, debug . You go to the page, the debugger went to the controller, from there to lib, executed the code there and returned it to the controller and from there to the view. It seems to be standard.
But, if you make changes to the code in fetcher.rb , then you have to restart the application every time, because the changes are not picked up on the fly. If you make changes in the controller, then everything is fine, but not in the lib.
In config/application.rb there is autoload enabled:

config.autoload_paths += %W[#{config.root}/lib]
    config.autoload_paths += Dir["#{config.root}/lib/**/"]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Demidenko, 2019-07-24
@Dem1

I would not touch the lib folder. And I created an app / lib folder and would place your services there.
But in theory, this is how it should work

config.autoload_paths << Rails.root.join("lib")
config.eager_load_paths << Rails.root.join("lib")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question