Ruby Rails Application

aj-geddes/useful-ai-prompts/skills/ruby-rails-application

作者 aj-geddes3f5182cfd739无许可证355 个星标收录于 2026年10月8日更新于 2026年10月8日仓库7个月前更新

Develop Ruby on Rails applications with models, controllers, views, Active Record ORM, authentication, and RESTful routes. Use when building Rails applications, managing database relationships, and implementing MVC architecture.

AI 生成的概览

指导构建 Ruby on Rails 应用,涵盖 Active Record 模型、RESTful 控制器、JWT 认证与数据库迁移。

功能
提供开发 Ruby on Rails 应用的参考指南与约定,涵盖项目初始化、Active Record 模型与关联、数据库迁移、RESTful 控制器、JWT 认证、Active Record 查询以及序列化器。该技能还附带一个模式校验脚本和一个迁移模板。产出的是 Rails 代码的指导与脚手架,而非完整应用。
适用场景
适用于构建或扩展 Rails Web 应用、定义模型关联、编写数据库迁移、创建 RESTful 控制器或加入基于 JWT 的认证时。面向遵循 Rails 约定的开发者。
运行要求
需要 Ruby on Rails 运行环境以及 PostgreSQL 等数据库,并能执行 Rails 命令。该技能附带一个可执行 shell 脚本和一个 SQL 迁移模板。

Ruby Rails Application

Table of Contents

Overview

Build comprehensive Ruby on Rails applications with proper model associations, RESTful controllers, Active Record queries, authentication systems, middleware chains, and view rendering following Rails conventions.

When to Use

  • Building Rails web applications
  • Implementing Active Record models with associations
  • Creating RESTful controllers and actions
  • Integrating authentication and authorization
  • Building complex database relationships
  • Implementing Rails middleware and filters

Quick Start

Minimal working example:

bash
rails new myapp --api --database=postgresqlcd myapprails db:create

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
Rails Project Setup [blocked]Rails Project Setup
Models with Active Record [blocked]Models with Active Record
Database Migrations [blocked]Database Migrations
Controllers with RESTful Actions [blocked]Controllers with RESTful Actions
Authentication with JWT [blocked]Authentication with JWT
Active Record Queries [blocked]Active Record Queries
Serializers [blocked]Serializers

Best Practices

✅ DO

  • Use conventions over configuration
  • Leverage Active Record associations
  • Implement proper scopes for queries
  • Use strong parameters for security
  • Implement authentication in ApplicationController
  • Use services for complex business logic
  • Implement proper error handling
  • Use database migrations for schema changes
  • Validate all inputs at model level
  • Use before_action filters appropriately

❌ DON'T

  • Use raw SQL without parameterization
  • Implement business logic in controllers
  • Trust user input without validation
  • Store secrets in code
  • Use select * without specifying columns
  • Forget N+1 query problems (use includes/joins)
  • Implement authentication in each controller
  • Use global variables
  • Ignore database constraints

来源与署名

来源:aj-geddes/useful-ai-prompts位于skills/ruby-rails-application提交3f5182c

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架