Ruby on Rails

Building web applications with Rails -- from quick tips on migrations and routes to deployment patterns and gem integrations.

Nested Forms in Rails 8: Life After Cocoon and Webpacker

accepts_nested_attributes_for still works. A small Stimulus controller handles the rest.

rails javascript how-to

Turbo Streams Instead of Nested Forms

When the parent already exists, you probably don't need a nested form at all

rails javascript how-to

Rails 6, Webpacker, and the Cocoon gem

A straightforward way to use the Cocoon gem in your Rails 6 project, using Webpacker.

rails how-to

Rails 6, Webpacker, and jQuery

Quickly add jQuery to your Rails 6 application using Webpacker

rails javascript how-to

Importing Heroku PostgreSQL to localhost

Importing a Heroku PostgreSQL database to your local machine, quickly and easily.

ops rails how-to

Imagemagick On Heroku-16

I recently encountered some strange memory issues after upgrading to Heroku-16. I was a little surprised at what I found regarding Imagemagick on Heroku.

ops rails how-to

Honeypot Captchas for Rails

A simple, unobtrusive way to try to combat automated form spam.

rails ruby open-source

Quick Tip: Rails Named Bind Variables

How to use named bind variables in a Ruby on Rails query to increase readability and reduce duplication.

rails how-to

Quick Tip: Cucumber Works-in-Progress

How to use the Cucumber tagging feature to tag scenarios.

rails testing how-to

Quick Tip: Rails Singularization of -ess

How to handle singularization of words like 'business' and 'address' through custom inflection rules in Ruby on Rails.

rails how-to

Fixing Multipart Uploads in Rack for Ruby 1.9

Patch your Rack installation after seeing an 'invalid byte sequence in US-ASCII' error.

ruby rails how-to

Using Named Scopes in a Rails Plugin

After extracting common functionality with named scopes into a Rails plugin, I was seeing some strange behavior. I describe the cause and solution.

rails ruby how-to

Quick Tip: Override Rails Generated URLs

Override the default Ruby on Rails generated URLs for a resource. It is a quick and simple way to change your URLs without changing your code.

rails how-to

Monitoring Thin using God, with Google Apps Notifications

A complete God config for monitoring Thin processes with email alerts via Google Apps SMTP

ops rails how-to

Installing aspell and raspell for Ultrasphinx

Resolving Ultrasphinx spell-checking warnings by installing aspell and its Ruby interface

ops rails how-to

Freebootr Ahoy!

Launching a pirate-themed site for finding and posting free items in your area

startups rails code

Quick Tip: Rails 2.1 Time Zones

Setting your application time zone in Rails 2.1 with config.time_zone

rails how-to

Nginx 405 Not Allowed Error

How page caching with nginx causes 405 errors on POST requests, and how to fix it

ops rails how-to

Quick Tip: Form Partials

A cleaner way to render shared form partials in Rails 2.1

rails how-to

Quick Tip: named_scope

Building chainable, reusable query scopes in Rails 2.1 with named_scope

rails how-to

Quick Tip: Route Associations

Simplify nested resource routes with has_one and has_many shorthand options

rails how-to

Quick Tip: has_many :through => checkboxes

Using Rails' auto-generated *_ids= setter to manage many-to-many associations via checkboxes

rails how-to

Quick Tip: Capistrano SSH Ports

How to configure Capistrano to connect on a custom SSH port

rails ops how-to

Rails Class Collisions

Working around Rails generator errors when existing constants collide with generated class names

rails how-to

RailsConf 2008

Heading to Portland for RailsConf with the Integrum team

events rails

Caching Locale-specific Dynamic JavaScript Files

Using ERB-rendered JavaScript with per-locale page caching in Rails

rails javascript how-to

Rails Tip: Precision and scale for decimals

How to specify precision and scale for decimal columns in Rails migrations using BigDecimal

rails how-to

Rails counter_cache problem

Why counter_cache only updates one parent when creating through an association, and how to fix it

rails how-to

Discover your missing specs

A rake task that finds app files without corresponding RSpec test files and generates them

rails testing how-to

Gravatar Problems

Debugging and fixing the Mephisto Gravatar caching plugin for production use

rails ops

Rails Testing Tips: Testing a helper with a block

Two approaches to testing a Rails helper method that accepts a block using RSpec

rails testing how-to

Rails Testing Tips: Stubbing controller methods in a helper test

In RSpec helper tests, the controller context is self -- use self.stub! to mock controller methods

rails testing how-to

Userstamps

Automatically recording created_by and updated_by user IDs on ActiveRecord models

rails how-to

Migration Timestamps deleted_at Magic Field

Extending Rails migration timestamps to automatically include a deleted_at column for acts_as_paranoid

rails how-to

Tuning a Pack of Mongrels

How to benchmark and determine the right number of Mongrel instances for your Rails app

rails ops how-to

Exploring Mongrel... Finally

A getting-started guide to Mongrel and Mongrel Cluster for serving Ruby on Rails applications

rails ops how-to

Getting Opinionated

How learning Ruby on Rails reignited my passion for software and changed the way I communicate

personal rails

Ruby on Rails Resources for Newbies

A curated list of books, screencasts, and subscriptions for learning Ruby on Rails

rails how-to

RailsConf 2007: Technology

Highlights from sessions on JavaScript, REST, Capistrano, Solr, and practical design for developers

events rails code

RailsConf 2007: Preparing for Portland

Preparing for RailsConf 2007 in Portland by watching DHH's keynote from last year

events rails

Rails Testing Tips: Login gotcha

A workaround for testing controllers that require admin login from a different controller

rails testing how-to

Rails Testing Tips: Code Coverage

Using rcov to track test coverage in a Ruby on Rails project

rails testing

Rails Testing Tips: flash.now gotcha

How to test flash.now values that get cleared after rendering the view

rails testing how-to

Contracting

Finishing my first contract project and discovering Ruby on Rails testing along the way

rails testing business

Render Partial for Email Template

A workaround for rendering partials inside Rails mail templates using relative paths

rails how-to

Rails Sweetness

Using single-table inheritance in Rails to model different address types for users and businesses

rails how-to

Thumbnails with RMagick

Generating proportionally scaled image thumbnails in Rails using ImageMagick and RMagick

rails how-to

Rails link_to and HTML options

How to pass HTML attributes like title to the Rails link_to helper method

rails how-to

Self-Referential, Many-to-Many Relationships

Modeling a friends list in Rails using has_and_belongs_to_many with a self-referencing join table

rails how-to

Salted Hash Login Generator

Tips for getting the Rails SaltedHashLoginGenerator working properly

rails how-to