RailsCasts Pro episodes are now free!

Learn more or hide this

Applied Filters: Pro Episodes xRefactoring x
Form Objects
Episode #416Jun 03, 2013335 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, 2012114 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, 201281 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, 201270 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, 201142 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, 2011122 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)