RailsCasts Pro episodes are now free!

Learn more or hide this

Applied Filters: Active Record x
Tagging
Episode #382Sep 22, 2012125 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)
Optimistic Locking (revised)
Episode #59Aug 04, 2012135 comments

Optimistic Locking (revised)

There is a chance one user will unintentionally override someone else's changes if they update a record near the same time. One solution is to use optimistic locking. The updated_at column can also be used for this as shown. (8 minutes)
Virtual Attributes (revised)
Episode #16Jul 20, 201271 comments

Virtual Attributes (revised)

Virtual attributes are a clean way to add form fields that do not map directly to the database. Here I show how to handle validations, associations, and more. (11 minutes)
Active Record Reputation System
Episode #364Jul 09, 2012105 comments

Active Record Reputation System

If you need to calculate an average user's rating or sum up a number of votes, consider using the activerecord-reputation-system gem. Here I will cover the basics and also briefly present a from-scratch solution. (10 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)
Squeel
Episode #354May 30, 201269 comments

Squeel

Squeel provides a comprehensive DSL for writing SQL queries in Ruby. It is built upon Arel giving you access to many of its powerful features. (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)
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)
Full-Text Search in PostgreSQL
Episode #343Apr 17, 2012131 comments

Full-Text Search in PostgreSQL

Postgres offers full-text searching right out of the box. This episode shows how to write queries from scratch, apply tools like Texticle and pg_search, and optimize performance through indexes. (16 minutes)
Migrating to PostgreSQL
Episode #342Apr 17, 2012137 comments

Migrating to PostgreSQL

Postgres is a feature-packed relational database that every Rails developer should consider using. Here you will learn how to install it, add it to a new application, and transition from an existing SQLite app using the "taps" gem. (8 minutes)