In development mode, the Grape API files in our Rails app aren't reloading as they should. We've tried the suggested approach in the Grape README, and referred to what seems to be the key SO post on it (Ruby on Rails 3 - Reload lib directory for each request) but it's not working for some reason.
In the config/application.rb:
config.paths.add File.join("app", "api"), glob: File.join("**", "*.rb")
config.autoload_paths += Dir[Rails.root.join("app", "api", "*")]
And in initializers/reload_api.rb:
if Rails.env == "development"
api_reloader = ActiveSupport::FileUpdateChecker.new(Dir[Rails.root.join('app', 'api', '**', '*.rb')]) do
puts ">>>> RELOADING!"
Rails.application.reload_routes!
end
ActionDispatch::Callbacks.to_prepare do
api_reloader.execute_if_updated
end
end
When I change a file under app/api, I can see the "RELOADING!" message in the log so I know the api_reloader callback is being invoked. But the changes are not taking effect. This makes me suspect the config.autoload_paths, but it all looks correct.
This is using Rails 3.2. Suggestions would be fantastic, since obviously it's super-annoying to not have reloading working on this stuff.