RailsCasts Pro episodes are now free!

Learn more or hide this

Applied Filters: model xRevised Episodes xActive Record 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)
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)
Polymorphic Association (revised)
Episode #154May 19, 201299 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)
Hackers Love Mass Assignment (revised)
Episode #26Mar 08, 201266 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)
Site-Wide Announcements (revised)
Episode #103Nov 12, 201295 comments

Site-Wide Announcements (revised)

Here I show how to add an announcement message at the top of every page in the application and allow the user to permanently hide it. This is all done test-first and even includes testing the JavaScript behavior. (11 minutes)
Thinking Sphinx (revised)
Episode #120Dec 09, 201144 comments

Thinking Sphinx (revised)

Sphinx is a full-text search engine for use with MySQL or PostgreSQL. Learn how to add Thinking Sphinx by defining an index on your model and searching with various options. (10 minutes)