The project is in a healthy, maintained state
Provides go-to-definition from *_path / *_url route helpers to the controller action the named route maps to.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 0.26.0, < 0.27.0
 Project Readme

ruby-lsp-rails-routes

A Ruby LSP add-on that adds go to definition from Rails route helpers to the controller action they map to.

ruby-lsp-rails already lets you jump from a *_path / *_url helper to its declaration in config/routes.rb. This add-on goes one step further: it resolves the named route to its controller action at runtime and offers the action's def line as an additional candidate. The routes.rb declaration is still offered, so both show up in the definition picker.

redirect_to users_path # go to definition -> UsersController#index (and config/routes.rb)

Requirements

  • ruby-lsp >= 0.26.0, < 0.27.0
  • ruby-lsp-rails — this add-on talks to its rails runner to resolve routes, so both must be installed.

Installation

Add the gem to your application's Gemfile:

group :development do
  gem 'ruby-lsp-rails-routes', require: false
end

Then run bundle install and restart the Ruby LSP server in your editor. The add-on is discovered automatically by Ruby LSP via the lib/ruby_lsp/**/addon.rb convention.

Scope

The route helper must be called with a self (or implicit) receiver. Route helpers reached through an explicit receiver (some_object.users_path), url_for, and polymorphic routes are not supported. Routes that do not map to a controller action (redirect, mounted Rack apps, mounted engines) are skipped.

License

MIT