跳至主要内容
小龙虾小龙虾AI
🤖

Rails

Build Rails applications with proper conventions, performance patterns, and security practices.

下载1.4k
星标2
版本1.0.1
安全合规
安全通过

技能说明


name: Rails slug: rails version: 1.0.1 description: Build reliable Rails apps avoiding ActiveRecord traps, N+1 queries, and callback pitfalls. metadata: {"clawdbot":{"emoji":"🛤️","requires":{"bins":["rails"]},"os":["linux","darwin","win32"]}}

Quick Reference

TopicFile
N+1, callbacks, validations, scopesactiverecord.md
Strong params, filters, rendercontrollers.md
Route conflicts, constraintsrouting.md
Partials, helpers, caching, XSSviews.md
ActiveJob, Sidekiq, retriesjobs.md
Mass assignment, CSRF, SQL injectionsecurity.md

Critical Rules

  • save returns false on failure — save! raises, check return or use bang
  • update_all/delete_all skip callbacks and validations — data corruption if unaware
  • find_each for batches — Model.all.each loads entire table into memory
  • redirect_to doesn't halt execution — code after it runs, use and return
  • dependent: :destroy missing — orphan records accumulate forever
  • default_scope pollutes all queries including joins — almost always wrong
  • Callbacks chain silently — throw :abort stops save but returns false, not exception
  • includes without references in where string — N+1 still happens
  • ||= memoization caches nil/false — use defined?(@var) ? @var : @var = compute
  • has_many through: vs has_and_belongs_to_many — latter has no join model for attrs
  • Nested before_action — multiple inheritance makes flow unreadable
  • render doesn't stop action — code continues, duplicate render crashes

如何使用「Rails」?

  1. 打开小龙虾AI(Web 或 iOS App)
  2. 点击上方「立即使用」按钮,或在对话框中输入任务描述
  3. 小龙虾AI 会自动匹配并调用「Rails技能完成任务
  4. 结果即时呈现,支持继续对话优化

相关技能