Define an array condition that selects on dynamic columns

Safely build dynamic SQL conditions from user-supplied column names and values; sanitize_sql_array works where placeholder syntax fails in MySQL.

Preloaded associations are filtered by conditions on the same table

Eager loading can unintentionally narrow has_many results when a where condition targets the joined table, even if the filter was only meant for the parent model.

Migrating from Elasticsearch to Opensearch: searchkick instructions (without downtime!)

Zero-downtime migration from Elasticsearch to OpenSearch for Searchkick apps, including staging validation, client switching, and environment-specific index settings.

danialfarid/angular-file-upload

Lightweight Angular JS file upload directive with old-IE support via FileAPI; Rails asset pipeline auto-loading can fail, so manual inclusion may be needed.

Claude Code Sandbox

Claude Code can run commands in a sandbox that blocks network traffic and limits file access, reducing permission prompts while still requiring careful trust.

Writing a README for a project

A project README gives new developers a quick overview, key architecture, and setup notes. Keep it concise, focused on essentials, and separate detailed class documentation.

Using Arel to Compose SQL Queries

Arel provides a Rails API for building SQL queries when where hashes are too limited. It exposes lower-level query composition through ActiveRecord.

ActiveRecord: String and text fields should always validate their length

String and text columns need model length validation to prevent database exhaustion and avoid runtime SQL errors on oversized input.

How to express ordinality with numbers in Rails

Turn integers into ordinal strings such as 1st or 2nd with ActiveSupport's ordinalize, including large and negative numbers.

remove_index fails silently for non-existing indexes in Rails 2 migrations

When you try to remove a non-existing index using remove_index, the migration will incorrectly pass without an error. The schema will not be changed, but the migration will be considered migrated.

Since this might be fixed in the future, you cannot mend your database by adding another migration on top of the faulty one. You should manually alter the database schema to the previous migration on all machines that migrated the faulty migration (inform your fellow developers), then delete the faulty migration from the repository.

jpmcgrath/shortener

Rails engine gem for creating branded short URLs on your own domain, resolving them for visitors, and collecting basic usage metrics.

XHR is not JSON

request.xhr? is not a reliable signal for JSON responses in Rails; respond_to respects the client’s Accept header and supports both HTML and JSON.

Caching may break relative paths in your merged stylesheet

Stylesheet caching can merge files from different folders and leave relative image paths pointing to the wrong location, so images work locally but fail on the server.

Eager-loading polymorphic associations

Polymorphic eager loading avoids n+1 queries, but includes can fail when ordering or filtering on joined tables; explicit joins or preload keep loading efficient.

Ruby constant lookup: The good, the bad and the ugly

Ruby constant resolution can pick the wrong class through namespace fallbacks, causing autoloading bugs and unexpected references in Rails, especially with nested models.

YAML: Keys like "yes" or "no" evaluate to true and false

Unquoted YAML keys like yes and no are parsed as booleans, so string keys must be quoted to avoid silent hash changes.

RSpec: Increase readability with super_diff

Hard-to-read RSpec diffs for nested hashes and collections can be improved with super_diff, which formats expectation mismatches more clearly.

Rails 3.1: Release candidate

Asset pipeline, HTTP streaming, jQuery as default framework, auto-reversable migrations, identity map for ActiveRecord.

Ruby 1.8.x support will be dropped with or after Rails 4.

Problems with Rails 3 Remote Links and Forms Using jQuery .live() in IE

There is a problem with AJAX response handling for Rails 3 remote links and forms in Internet Explorer. This problem affects applications still using jQuery 1.4.2.

Using SSL in Rails 3

SSL in Rails 3 is non-obvious.

rhulse's rails-css-views at master - GitHub

This gem is designed to provide CSS views to Rails, and a process to concatenate and minify these files to one file for production.

Automatic Flushing: The Rails 3.1 Plan « Katz Got Your Tongue?

This post explains, in some detail, how we will implement a nice performance boost for Rails developers. Understanding the details might help gain the full benefits of the optimization, but you will gain some benefits even if you have no idea how it works.

The Rails Internationalization (I18n) API

This guide will walk you through the I18n API and contains a tutorial how to internationalize a Rails application from the start.

Translations available in rails

YAML List of all translations currently available in Rails