Zum Inhalt springen

HTTP action naming (ARCH6004)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key ruby.naming.controller-action-naming · Severity info · Category naming

For RESTful consistency, controller action names should match the semantics of the HTTP verb they handle. GET requests should map to index/show, POST to create; names that contradict the verb (a create on a GET) mislead readers.

class ArticlesController < ApplicationController
# GET /articles
def create_list
@articles = Article.all
end
end
class ArticlesController < ApplicationController
# GET /articles
def index
@articles = Article.all
end
end

Rename the action to the RESTful name that matches its HTTP verb (GET→index/show, POST→create).