4

How can I force Rails 3.2 to reload mounted rack app per request in development mode?

I have mounted grape app this way

 mount API2, :at => "/api2"

However rails doesn't reflect changes in app without web server restart.

Alexey Zakharov
  • 24,694
  • 42
  • 126
  • 197

1 Answers1

5

Refer: https://stackoverflow.com/a/4368838/667158

# Reload Grape in development mode
api_reloader = ActiveSupport::FileUpdateChecker.new(Dir["path/to/you/api/dir/**/*"], true) do
  Rails.application.reload_routes! # or do something better here
end

ActionDispatch::Callbacks.to_prepare do
  api_reloader.execute_if_updated
end
Community
  • 1
  • 1
Ian Yang
  • 1,091
  • 8
  • 20