RailsCasts Pro episodes are now free!

Learn more or hide this

Applied Filters: model xActive Record x
Model Caching (revised)
Episode #115 – May 13, 2013 – 426 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 #196 – Apr 19, 2012 – 228 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)
Model Name in URL (revised)
Episode #63 – Dec 16, 2012 – 85 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)
Nested Model Form Part 1
Episode #196 – Jan 11, 2010 – 184 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)
Public Activity
Episode #406 – Feb 13, 2013 – 155 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)
Polymorphic Association (revised)
Episode #154 – May 19, 2012 – 99 comments

Polymorphic Association (revised)

A polymorphic association allows a model to belong_to different types of other models. Here I show how to make a single comment model belong to articles, photos, and events. (11 minutes)
Tableless Model
Episode #193 – Dec 21, 2009 – 55 comments

Tableless Model

If you want to create a model without a database backend, you simply need to define a couple methods in the model like I show in this episode. (8 minutes)
Hackers Love Mass Assignment (revised)
Episode #26 – Mar 08, 2012 – 66 comments

Hackers Love Mass Assignment (revised)

One of the most common security issues in a Rails application is the mass-assignment vulnerability which allows a user to set any attribute on the model. Learn how to prevent it in this episode. (6 minutes)
Model Versioning
Episode #177 – Aug 31, 2009 – 56 comments

Model Versioning

If you need to keep track of a model's history of changes and switch between versions, consider using the vestal_versions gem like I show in this episode. (9 minutes)
Tagging
Episode #382 – Sep 22, 2012 – 125 comments

Tagging

There are several gems to help implement tags in a Rails app. Here I show you how to integrate acts-as-taggable-on and then show how to do it from scratch. (11 minutes)