instance method from_requirements

Ruby on Rails 8.0.4

Since v7.2.3

Available in: v7.2.3 v8.0.4 v8.1.2

Signature

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”)

Parameters

requirements req
Source
# File actionpack/lib/action_dispatch/routing/route_set.rb, line 29
      def from_requirements(requirements)
        routes.find { |route| route.requirements == requirements }
      end

Defined in actionpack/lib/action_dispatch/routing/route_set.rb line 29 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionDispatch::Routing::RouteSet

Type at least 2 characters to search.

↑↓ navigate · open · esc close