Analyze and search Rails routes
Analyzes Rails routes, searches by pattern or controller, and identifies RESTful patterns and helpers.
/plugin marketplace add bastos/rails-plugin/plugin install bastos-ruby-on-rails@bastos/rails-pluginsearch-term-or-actionRoutes request: $ARGUMENTS
Available actions:
| Action | Description |
|---|---|
| (empty) | Show all routes |
[search] | Search routes by path, controller, or helper |
controller:[name] | Show routes for specific controller |
unused | Find controllers/actions without routes |
Execute based on request:
Show all routes:
rails routes
Search routes:
rails routes -g [search-term]
Controller-specific:
rails routes -c [controller-name]
Output format:
Prefix Verb URI Pattern Controller#Action
articles GET /articles(.:format) articles#index
article GET /articles/:id(.:format) articles#show
POST /articles(.:format) articles#create
Analyze the routes and provide:
Route summary:
For search results:
Route helpers for views/controllers:
articles_path # GET /articles
article_path(@article) # GET /articles/:id
new_article_path # GET /articles/new
edit_article_path(@article) # GET /articles/:id/edit
Identify potential issues:
Common route patterns:
# RESTful resources
resources :articles
# Nested resources
resources :articles do
resources :comments, only: [:create, :destroy]
end
# Member and collection routes
resources :articles do
member do
post :publish
end
collection do
get :drafts
end
end
# Namespace
namespace :admin do
resources :users
end
If showing all routes results in too many, group them by controller and summarize.