Suppose I have a route defined as follows:
constraints MyRouteConstraint.new do get ':param/:param1/:param2', to: 'controller#action' end
How can I get the pattern ': param /: param1 /: param2' in my controller? I know that Rails.application.routes.recognize_path is "/ param / param1 / param2", but it causes the error "No route matching"
update:
Rails.application.routes.router.recognize(request) do |route, matches, parameters| return route.path.spec.to_s if route.path.required_names.all? { |p| request.params.keys.include? p } end.flatten.compact.first
ruby-on-rails ruby-on-rails-4 routes
Sergii kushch
source share