Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Applied Filters: Refactoring x
Form Objects
Episode #416Jun 03, 201343 comments

Form Objects

Models have a tendency to become a complex mess as an application grows. In this episode you will learn a couple of techniques to extract form-behavior out into its own class. (18 minutes)
Service Objects
Episode #398Dec 18, 201248 comments

Service Objects

Models can quickly become a grab-bag of unrelated methods if behavior is constantly being pushed from the controller. Here I show how to refactor this using Concerns and Service Objects. (12 minutes)
STI and Polymorphic Associations
Episode #394Nov 25, 201220 comments

STI and Polymorphic Associations

Single Table Inheritance (STI) can help organize branching logic into separate classes, but a polymorphic association may be a better fit if there are unique database columns. (14 minutes)
Hacking with Arel
Episode #355May 30, 201213 comments

Hacking with Arel

Here I show a variety of ways to rewrite a long SQL query using only Active Record and Arel. This includes generating scopes dynamically, adding an "or" operator, and adding a powerful "match" method. (15 minutes)
Form Builders
Episode #311Dec 26, 201115 comments

Form Builders

Forms often follow a similar pattern with a lot of repetition. Learn how to clean up form views and remove duplication with the help of form builders. (12 minutes)
Presenters from Scratch
Episode #287Oct 03, 2011102 comments

Presenters from Scratch

Clean up complex view logic with the help of presenters, and doing this from scratch gives you a lot of flexibility. Here I show not only how to create presenters, but how to test them using Test Unit and RSpec. (14 minutes)
Draper
Episode #286Oct 03, 201150 comments

Draper

Clean up complex view logic using Draper. This gem provides decorators (much like presenters) which bundles view logic in an object oriented fashion. In this episode I do a step-by-step refactoring of a complex template into a decorator. (12 minutes)
How I Test
Episode #275Jul 18, 2011118 comments

How I Test

Here I show how I would add tests to the password reset feature created in the previous episode. I use RSpec, Capybara, Factory Girl, and Guard to make request, model, and mailer specs. (15 minutes)
Refactoring & Dynamic Delegator
Episode #212May 03, 201023 comments

Refactoring & Dynamic Delegator

Learn how to refactor a set of conditional Active Record queries using a Dynamic Delegator. (7 minutes)
Site Wide Announcements
Episode #103Apr 28, 200840 comments

Site Wide Announcements

Sometimes you need to display an administrative announcement to every page on the site and give the users the ability to hide the announcement. See how in this episode. (13 minutes)