RailsCasts Pro episodes are now free!

Learn more or hide this

Applied Filters: model x
Model Caching (revised)
Episode #115May 13, 2013426 comments

Model Caching (revised)

Caching at a low level is a great option when the view is too dynamic to cache and you need something flexible that can work anywhere in the application. Here I show a variety of ways to use Rails.cache with Active Record. (12 minutes)
Nested Model Form (revised)
Episode #196Apr 19, 2012228 comments

Nested Model Form (revised)

Handling multiple models in a single form is easy with accepts_nested_attributes_for. Here you will also learn how to add and remove nested records through JavaScript. (11 minutes)
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)
Model Name in URL (revised)
Episode #63Dec 16, 201285 comments

Model Name in URL (revised)

A model's ID in the URL is not very helpful to the user. Consider adding the name which can also improve SEO. Learn how to override to_param, add a slug attribute, and make a catch all route for deep nesting. (9 minutes)
Active Model Serializers
Episode #409Mar 09, 2013139 comments

Active Model Serializers

The ActiveModel::Serializers gem can help you build JSON APIs through serializer objects. This provides a dedicated place to fully customize the JSON output. (10 minutes)
Nested Model Form Part 1
Episode #196Jan 11, 2010184 comments

Nested Model Form Part 1

Handling multiple models in a single form is much easier with the accepts_nested_attributes_for method. See how to use this method to handle nested model fields. (11 minutes)
Nested Model Form Part 2
Episode #197Jan 18, 2010215 comments

Nested Model Form Part 2

Add and remove nested model fields dynamically through JavaScript using either Prototype or jQuery. (12 minutes)
Public Activity
Episode #406Feb 13, 2013155 comments

Public Activity

Learn how to easily add a user activity feed using the public_activity gem. Here I show both the default setup using model callbacks and a manual way to trigger activities. (10 minutes)
Active Model
Episode #219Jun 21, 201053 comments

Active Model

In Rails 3 the non-database functionality of Active Record is extracted out into Active Model. This allows you to cleanly add validations and other features to tableless models. (6 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)