You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My suggestion is to have a cop, which checks, that all defined routes in config/routes.rb have corresponding controller actions. For example, if we define:
resources:countries
the following routes are generated:
countries GET /countries(.:format) countries#index
POST /countries(.:format) countries#create
new_country GET /countries/new(.:format) countries#new
edit_country GET /countries/:id/edit(.:format) countries#edit
country GET /countries/:id(.:format) countries#show
PATCH /countries/:id(.:format) countries#update
PUT /countries/:id(.:format) countries#update
DELETE /countries/:id(.:format) countries#destroy
However, if the controller has only implemented the #index action:
One slight complication: It's possible to have a view template be rendered even if there is no corresponding controller action, if it's named accordingly. (But I normally prefer to be explicit and have an empty controller method).
My suggestion is to have a cop, which checks, that all defined routes in
config/routes.rb
have corresponding controller actions. For example, if we define:the following routes are generated:
However, if the controller has only implemented the
#index
action:the cop should raise an error/warning.
The text was updated successfully, but these errors were encountered: