Active Record models are the foundation of every good Rails application. Learn how to get the most out of the Active Record features that you use on a day-to-day basis from a popular Rails developer and screencaster. In these screencasts, Ryan Bates incrementally builds the models for a Rails application and refactors them over time to address new features. All the code is based on Rails 2.1 features.

Throughout these 20-30 minute screencast episodes, you’ll get inside the mind of an experienced Rails developer: his thought processes, his development techniques, the tools he uses, and the tricks of the trade. You can follow along as he adds new features to shape the application over time. You’ll also see how he troubleshoots problems along the way. You’ll not only learn more about Active Record, you’ll also see ways to streamline your development workflow.

  • Watch the application preview highlighting the application Ryan builds in these screencasts.
    (1 min, QuickTime | Ogg)
Everyday Active Record
Code Discussions FAQ
  • Download and watch DRM-free episodes when and where it's convenient for you
  • You get both QuickTime and iPod/iPhone formats, and Theora Ogg format for select topics
  • Only $5 per episode!

Buy Now

This screencast series is still being recorded. Stay tuned for more new episodes!

 

Episode Contents

  • Episode 1: Designing Models with Associations

    We’ll start by creating the Movie, Review, Showing, and Theatre models, then knit them together with associations to bring the cinemas application to life. You’ll learn how to:

    • create models with their respective database tables
    • use one-to-many and many-to-many associations
    • apply guidelines for when to choose a particular association
    • create a join model with a :through association
    • navigate between associated models
  • Episode 2: Finding and Scoping Models

    We’ll pick up where we left off by fetching models using the find method with several options, including the new Rails 2.1 named_scope method. You’ll learn how to:

    • perform finds on models using various find options
    • write class methods to encapsulate complex find operations
    • use the new Rails 2.1 named_scope method to elegantly constrain queries and make controllers easier to read
    • perform calculations using the built-in calculation methods
    • use more advanced find options such as :include
  • Episode 3: Validating Models

    Validations are the key to preserving data integrity in Rails. We’ll use both built-in and custom validations to make sure movie reviews are submitted with valid data. You’ll learn how to:

    • use built-in validation methods
    • handle form errors conveniently
    • add custom validations using the validate method
    • validate across multiple database columns
    • make validations conditional based on authentication
    • handle validations across multiple models that are associated
  • Episode 4: Using Callbacks

    Callbacks are a way for your application to hook into the lifecycle of Active Record models. In this episode, we’ll use callbacks to solve two database performance problems. We’ll cache a movie’s review count and its average number of stars. You’ll learn how to:

    • use Active Record callback methods
    • make callbacks conditional
    • apply before_save and before_destroy callbacks to keep cache data consistent
    • use the counter_cache option on associations
    • track dirty columns
    • destroy dependent records
    • apply other callback tips
  • Episode 5: Performance Optimizations is in the recording studio and will be released soon.

Audience

These screencsts are designed for beginner and intermediate Rails developers, but even the more experienced developers will get something out of the later episodes.

About the Episodic Style

Watching developers work is like getting inside their head. Just by sitting beside them as they work, you can learn a bunch of tricks to help improve your workflow. And when experts do their best work, it's usually not a linear process where everything is planned out in advance and works the first time. Building applications is more organic than that. It's like watching a series of programming episodes.

These episodes were designed to help you learn in a significantly different way than reading through the books. In fact, screencasts complement the narrative in books by showing you how it's done using elements of time and motion. Seeing is believing!

We currently have a few episodes to start the "season", and we'll release new episodes over time (generally every week or two). Source code is available for each episode, including all of the work that has been done up to that point. So, you can pop in to episodes out of order and have the code you need to get started. We don't know exactly how many episodes there will be for any given series. If you've purchased an episode in a particular screencast series, and your account is configured to receive e-mail announcements from us, we’ll send you an e-mail when new episodes are released for that series.

About the Screencaster

Ryan Bates has been involved in web development since 1998. In 2005 he started working professionally with Ruby on Rails and is now best known for his work on Railscasts, the free Ruby on Rails screencast series.