Class: RuboCop::Cop::Appdev::NoResourcefulRoutes
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Appdev::NoResourcefulRoutes
- Defined in:
- lib/rubocop/cop/appdev/no_resourceful_routes.rb
Overview
Forbids ‘resources` and `resource` in `config/routes.rb`. Authors must write explicit verb-mapped routes so students see every URL, controller, and action spelled out.
‘root`, `namespace`, `scope`, `mount`, `match`, and the HTTP verb methods (`get`, `post`, `put`, `patch`, `delete`) are all allowed.
Scoped to ‘config/routes.rb` via `Include:` in default.yml.
Constant Summary collapse
- MSG =
"Don't use `%<method>s` in routes; write explicit verb mappings like `get(\"/...\", { :controller => \"...\", :action => \"...\" })`."- RESTRICT_ON_SEND =
[:resources, :resource].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
26 27 28 |
# File 'lib/rubocop/cop/appdev/no_resourceful_routes.rb', line 26 def on_send(node) add_offense(node, message: format(MSG, method: node.method_name)) end |