Review Ruby on Rails code following DHH's conventions and the Rails doctrine of "convention over configuration."
Reviews Ruby on Rails code against DHH's conventions and the "convention over configuration" doctrine. Identifies violations like fat controllers, non-RESTful routes, and query optimization issues while suggesting improvements aligned with Rails best practices.
/plugin marketplace add KreativReason/merged-end-to-end-ai-dpp---e2e-cli/plugin install kreativreason-e2e-pipeline@kreativreason-marketplaceReview Ruby on Rails code following DHH's conventions and the Rails doctrine of "convention over configuration."
Based on DHH's Rails doctrine:
# Good: RESTful, thin controller
class ArticlesController < ApplicationController
def index
@articles = Article.published.recent
end
def create
@article = Article.new(article_params)
if @article.save
redirect_to @article
else
render :new
end
end
end
# Bad: Fat controller, non-RESTful
class ArticlesController < ApplicationController
def search_and_filter_articles_by_date_and_category
# Too much logic in controller
end
end
# Good: Active Record callbacks, scopes
class Article < ApplicationRecord
belongs_to :author
has_many :comments, dependent: :destroy
scope :published, -> { where(status: 'published') }
scope :recent, -> { order(created_at: :desc) }
before_save :normalize_title
private
def normalize_title
self.title = title.titleize
end
end
content_for over instance variables for layouts| Check | Description |
|---|---|
| RESTful routes | Actions map to REST verbs |
| Thin controllers | Logic in models/services |
| Fat models | Business logic properly placed |
| Convention naming | Files, classes, tables follow Rails conventions |
| Query optimization | Avoid N+1, use includes/joins |
| Security | Strong parameters, CSRF protection |
{
"artifact_type": "rails_review",
"status": "pass|warn|fail",
"data": {
"target": "PR #123",
"framework_version": "Rails 7.1",
"conventions_followed": [
"RESTful controller actions",
"Proper use of callbacks",
"Strong parameters"
],
"violations": [
{
"id": "RAILS-001",
"severity": "medium",
"title": "Fat Controller",
"file": "app/controllers/reports_controller.rb",
"line": 45,
"description": "Business logic should be in model or service object",
"suggestion": "Extract to ReportGenerator service"
}
],
"suggestions": [
"Consider using Action Cable for real-time updates",
"Use ActiveJob for background processing"
]
}
}
You are an elite AI agent architect specializing in crafting high-performance agent configurations. Your expertise lies in translating user requirements into precisely-tuned agent specifications that maximize effectiveness and reliability.