- Always use the
rails generate migrationcommand to create migration files. - Use
textoverstringif length varies significantly. - Wrap multi-record operations in transactions. Use
save!(bang) inside transactions. - Keep scopes as one-liners. Complex queries belong in search/query objects.
- Never use
Post.allwithout pagination. - Avoid
.countin loops. - Use
counter_cache.