简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM