How-To

Practical guides and quick tips for solving specific problems.

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

Easily Add An Instagram Feed To Jekyll

How to easily add an Instagram feed to your Jekyll site, while avoiding the gotchas.

code javascript 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

IE tries to be helpful when using JavaScript to set the href attribute

When using JavaScript to set the href attribute of an anchor tag, IE sometimes updates the inner HTML. Why does this happen and what are some solutions?

javascript how-to

IE7 resize window problem

I describe a problem encountered in IE7 when dealing with a centered body and relatively positioned elements that appeared to have a fixed position.

javascript how-to

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

Enable Secure Admin for Wordpress

Secure your Wordpress administration area using a self-signed certificate and Nginx webserver.

ops how-to

SEO Resources for Dummies (i.e., me)

My experiences with learning search engine optimization (SEO) to help the ranking of Millarian.

seo 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

Error after upgrading SliceHost

Fixing the INLINEDIR/HOME TemplateError that appears after a SliceHost upgrade

ops ruby how-to

Quick Tip: Setting an SPF record

Adding a DNS TXT record to stop Google Apps from rejecting your Rails app's outgoing email

ops how-to

Quick Tip: Rails 2.1 Time Zones

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

rails how-to

Quick Tip: Setting time zone on Ubuntu Hardy

A one-command way to configure the time zone on your Ubuntu server

ops 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: SSH Backspace

Fixing the broken backspace key when using SSH from Mac Terminal

ops 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

Quick Tip: SSH Config

Create short hostname aliases in ~/.ssh/config to simplify SSH connections

ops how-to

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

Minor TextMate Annoyance

Customizing the TextMate do snippet to omit the block variable by default

code how-to

The Tip of the Ruby #1

Understanding the difference between or and || operator precedence in Ruby

ruby how-to

Search Engine Optimization for Coders

Notes from a Desert Code Camp talk on practical SEO tips for developers

seo code 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

Firefox Profiles

Using Firefox profiles to separate your development extensions from personal browsing

code how-to

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

iBug

Firebug for the iPhone -- a small webserver that forwards log messages to the Firebug console

code 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

Ruby on Rails Resources for Newbies

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

rails how-to

Google Maps API with large data sets

Exploring optimization techniques for displaying thousands of markers on a Google Map

javascript how-to

Ruby Time Limitations

Ruby's Time class has platform-dependent minimum values -- use Date or DateTime instead

ruby how-to

Firebug Intro

A video introduction to the Firebug Firefox add-on for debugging JavaScript, Ajax, and CSS

code how-to

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: flash.now gotcha

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

rails testing how-to

Dissecting a Regular Expression

Breaking down a Ruby regex that extracts a file extension from filenames with spaces and multiple dots

code how-to

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