class OldRoutesConstraint
def self.matches?(request)
# TO-DO: add a check to make sure this code block runs only if no other url matches.
path = {}
begin
_routes = Bangthetable::Application.routes
_routes.disable_clear_and_finalize = true
_routes.clear!
_routes.draw do
# here you can add any route you want
# and there will only be routes that are listed below in routes.
get "/documents/show/:id", :to => "sessions#new"
end
ActiveSupport.on_load(:action_controller) { _routes.finalize! }
path = (Rails.application.routes.recognize_path(request.env["PATH_INFO"], :method => request.env["REQUEST_METHOD"].to_sym) rescue {}) || {}
ensure
_routes.disable_clear_and_finalize = false
Bangthetable::Application.routes_reloader.paths.each{ |path| load(path) }
# this is where we are reloading the original v2 routes.
# do not remove this piece of code. Coz from next requests, app will fail.
end
Bangthetable::Application.routes_reloader.paths.each{ |path| load(path) }
return path.has_key?(:controller)
end
end