class Konmari::Routes::RailsReloader
When using Rails, any changes to config/routes.rb
are detected by the server when developing and automatically reloaded.
In order to mimic this behavior, add {Konmari::Routes::RailsReloader} as middleware in your development.rb
file:
Rails.application.configure do config.middleware.use Konmari::Routes::RailsReloader ... end
Public Class Methods
new(app)
click to toggle source
# File lib/konmari/routes/rails_reloader.rb, line 14 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/konmari/routes/rails_reloader.rb, line 18 def call(env) routes_reloader.execute_if_updated return *@app.call(env) end
Private Instance Methods
rails_routes()
click to toggle source
# File lib/konmari/routes/rails_reloader.rb, line 31 def rails_routes {Rails.root.join("config/routes").to_s => ["routes", "rb"]} end
routes_reloader()
click to toggle source
# File lib/konmari/routes/rails_reloader.rb, line 24 def routes_reloader @routes_reloader ||= ActiveSupport::FileUpdateChecker.new([], rails_routes) do Rails.logger.info "Change detected, reloading routes..." Rails.application.reload_routes! end end