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.

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.

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.

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.

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.

Beware of params with non-string values (nil, array, hash)

params can contain nil, arrays, or hashes, so treating request values as plain strings can lead to unsafe lookups and unexpected matches.

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.

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.

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.

RSpec: Applying stubs only within a block

RSpec mocks normally persist for a spec; RSpec::Mocks.with_temporary_scope limits temporary stubs to a block and releases them afterward.

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.

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

Rails 2.3 Nested Object Forms: I’m not Crazy about Them « SmartLogic Solutions Blog

I just finished reviewing Rails 2.3 Nested Object Forms. While a very nice and “magical” feature, I’ve got to admit that I’m really not that crazy about how it works.

Rails plugin testing guide

This article is an introduction to testing Rails plugins.

The Bark Blog » Testing Rails Model Plugins

Unfortunately, by default plugin tests are pretty bland. They use the plain unit test suite supplied by Ruby, and not any of the extended Rails test framework. This will leave our plugin’s test classes with no access to fixtures, database.yml configuration, or any of those nice class auto-loading features.