Rails 3.2.3. I have a Rails app with /lib
in in my autoload paths. One of my library files is requiring a bunch of files like so
Dir[Rails.root.join("lib/foo/*.rb")].each { |f| require f }
In development, those files don't reload if I change them. For example, if I modify /lib/foo/bar.rb
, I will have to restart the server to see those changes. Can anyone suggest a way so that on each request they are reloaded properly?
require
doesn't play very nicely with rails' autoloading system.
require_dependency
will do pretty much what require does but keeps the autoloading system in the loop so that the loaded constants will get unloaded at the end of the request. You may need to ensure that the files are in rails' autoload paths
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With