123456789_123456789_123456789_123456789_123456789_

Class: ActionDispatch::Routing::RouteSet

Relationships & Source Files
Namespace Children
Modules:
Extension / Inclusion / Inheritance Descendants
Subclasses:
Rails::Engine::LazyRouteSet
Inherits: Object
Defined in: actionpack/lib/action_dispatch/routing/route_set.rb

Overview

The RouteSet contains a collection of Route instances, representing the routes typically defined in config/routes.rb.

Instance Method Summary

Instance Method Details

#from_requirements(requirements)

Returns a Route matching the given requirements, or nil if none are found.

This is intended for use by tools such as Language Servers.

Given the routes are defined as:

resources :posts

Then the following will return the Route for the show action:

Rails.application.routes.from_requirements(controller: "posts", action: "show")
[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/routing/route_set.rb', line 29

def from_requirements(requirements)
  routes.find { |route| route.requirements == requirements }
end