<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/coding-guidelines-1x9sh8pl0" -->

---
title: Coding guidelines | daily.dev
description: A personal, opinionated set of coding guidelines spanning general programming principles, Ruby-specific style choices, and Rails conventions. Covers encryption...
canonical: https://daily.dev/posts/coding-guidelines-1x9sh8pl0
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Coding guidelines | daily.dev
og:description: A personal, opinionated set of coding guidelines spanning general programming principles, Ruby-specific style choices, and Rails conventions. Covers encryption...
og:url: https://daily.dev/posts/coding-guidelines-1x9sh8pl0
og:image: https://api.daily.dev/og/posts/1X9SH8pL0.png
og:image:alt: Coding guidelines
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Coding guidelines

**[Ruby Flow](https://daily.dev/sources/rubyflow)** · 6 min read · 2 upvotes · 0 comments

## Summary

A personal, opinionated set of coding guidelines spanning general programming principles, Ruby-specific style choices, and Rails conventions. Covers encryption of personal data, optimistic coding, method naming, git commit discipline, test coverage, file length limits, avoiding metaprogramming and service objects, RuboCop-enforced formatting rules, and Rails-specific practices like Turbo defaults, reversible migrations, Active Record custom types, PostgreSQL native types (citext, arrays, enums), and query caching. A full example builds a Train model, controller, migration, and view demonstrating the guidelines in practice.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://claudiob.github.io/style>

## Questions this post answers

### How do I add strict locals to a Rails partial to avoid passing instance variables?

Declare locals explicitly at the top of the partial using the magic comment syntax, for example `<%# locals: (train:) -%>`, instead of relying on instance variables leaking into the view. This makes the partial's required inputs explicit and prevents accidental coupling to controller-set instance variables.

_Developers tightening up Rails view conventions can find practical examples like this one through daily.dev._

### How do I make a Postgres column encrypted but still queryable in Rails 8?

Use Active Record encryption with the deterministic option set to allow querying, for example adding `deterministic: { fixed: false }` to an encrypted email column, which lets you run lookups like `User.find_by(email:)` while keeping the value encrypted at rest.

_Rails developers balancing data privacy with query needs can track patterns like this via daily.dev._

### How do I create a native PostgreSQL enum column in a Rails migration?

Use the `create_enum` migration method to declare a Postgres-backed enum type by name rather than storing integers, then reference it on a column with `t.enum :status, enum_type: :train_status`. This leverages PostgreSQL's native enum type instead of Rails' integer-backed enum mapping.

_Teams adopting Postgres-native types in Rails migrations can keep up with such techniques on daily.dev._

## Similar posts on daily.dev

- [Enforcing Your Ruby Style Guide on AI-Generated Code](https://daily.dev/posts/enforcing-your-ruby-style-guide-on-ai-generated-code-flixahyod) · thoughbot · 1 upvotes · 0 comments
- [Tips for effective prototyping with Rails 8 and Claude Code](https://daily.dev/posts/tips-for-effective-prototyping-with-rails-8-and-claude-code-h5acnjzue) · Ruby Flow · 0 upvotes · 0 comments
- [Better guides, better framework](https://daily.dev/posts/better-guides-better-framework-u808pzsy9) · Rails · 0 upvotes · 0 comments
- [One year of Ruby on Rails configuration](https://daily.dev/posts/one-year-of-ruby-on-rails-configuration-3xgfj4tsp) · RUBYLAND · 2 upvotes · 0 comments
- [Rails Security Best Practices: A Comprehensive Guide](https://daily.dev/posts/rails-security-best-practices-a-comprehensive-guide-4klfoqpgy) · Saeloun · 0 upvotes · 0 comments

---

Tags: [#postgresql](https://daily.dev/tags/postgresql), [#ruby](https://daily.dev/tags/ruby), [#rails](https://daily.dev/tags/rails)

[View this post on daily.dev](https://daily.dev/posts/coding-guidelines-1x9sh8pl0)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Coding guidelines","url":"https://daily.dev/posts/coding-guidelines-1x9sh8pl0","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/coding-guidelines-1x9sh8pl0"},"datePublished":"2026-08-24T02:25:09.482Z","dateModified":"2026-09-14T07:55:43.453Z","description":"A personal, opinionated set of coding guidelines spanning general programming principles, Ruby-specific style choices, and Rails conventions. Covers encryption...","image":"https://media.daily.dev/image/upload/s--OHB84bZF--/f_auto/v1722860399/public/Placeholder%2010","thumbnailUrl":"https://media.daily.dev/image/upload/s--OHB84bZF--/f_auto/v1722860399/public/Placeholder%2010","isAccessibleForFree":true,"articleSection":"Ruby Flow","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Ruby Flow","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/a21aaa8bcbbf448193a016895c90a0e1","url":"https://daily.dev/sources/rubyflow"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/coding-guidelines-1x9sh8pl0","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"postgresql,ruby,rails","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Ruby Flow","item":"https://daily.dev/sources/rubyflow"},{"@type":"ListItem","position":3,"name":"Coding guidelines"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/coding-guidelines-1x9sh8pl0#faq","mainEntity":[{"@type":"Question","name":"How do I add strict locals to a Rails partial to avoid passing instance variables?","acceptedAnswer":{"@type":"Answer","text":"Declare locals explicitly at the top of the partial using the magic comment syntax, for example `<%# locals: (train:) -%>`, instead of relying on instance variables leaking into the view. This makes the partial's required inputs explicit and prevents accidental coupling to controller-set instance variables. Developers tightening up Rails view conventions can find practical examples like this one through daily.dev."}},{"@type":"Question","name":"How do I make a Postgres column encrypted but still queryable in Rails 8?","acceptedAnswer":{"@type":"Answer","text":"Use Active Record encryption with the deterministic option set to allow querying, for example adding `deterministic: { fixed: false }` to an encrypted email column, which lets you run lookups like `User.find_by(email:)` while keeping the value encrypted at rest. Rails developers balancing data privacy with query needs can track patterns like this via daily.dev."}},{"@type":"Question","name":"How do I create a native PostgreSQL enum column in a Rails migration?","acceptedAnswer":{"@type":"Answer","text":"Use the `create_enum` migration method to declare a Postgres-backed enum type by name rather than storing integers, then reference it on a column with `t.enum :status, enum_type: :train_status`. This leverages PostgreSQL's native enum type instead of Rails' integer-backed enum mapping. Teams adopting Postgres-native types in Rails migrations can keep up with such techniques on daily.dev."}}]}
```

