active-record episodes

#2
Mar 07

Dynamic find_by Methods

Shorten simple finds considerably and improve readability by using the dynamic find_all_by and find_by methods.
Download (4.8 MB, 1:28)
alternative download for iPod & Apple TV (2.5 MB, 1:28)
#3
Mar 09

Find Through Association

No need to pass foreign keys in find conditions, just do the find through a has_many association.
Download (5.2 MB, 2:17)
alternative download for iPod & Apple TV (3.2 MB, 2:17)
#4
Mar 12

Move Find into Model

Move a find into the model to clean up the controllers and remove duplication. Also see how you can call these custom find methods through an association.
Download (4.8 MB, 2:03)
alternative download for iPod & Apple TV (2.8 MB, 2:03)
#5
Mar 14

Using with_scope

Learn how to use with_scope - a very powerful method which will allow your custom find methods to accept any find options. Just like magic!
Download (5.9 MB, 2:50)
alternative download for iPod & Apple TV (3.9 MB, 2:50)
#14
Apr 04

Performing Calculations on Models

Did you know ActiveRecord provides class methods for performing calculations on models? You can even use these methods through associations.
Download (11.7 MB, 2:57)
alternative download for iPod & Apple TV (3.9 MB, 2:57)
#15
Apr 06

Fun with Find Conditions

You can pass more than simple strings to find conditions. Arrays, ranges, and nil values can be passed as well. In this episode you will see the tricks involved with passing these odd objects to find conditions. (Update: audio fixed).
Download (17.5 MB, 4:31)
alternative download for iPod & Apple TV (8.2 MB, 4:31)
#16
Apr 09

Virtual Attributes

Keep your controllers clean and forms flexible by adding virtual attributes to your model. This very powerful technique allows you to create form fields which may not directly relate to the database.
Download (10.5 MB, 3:41)
alternative download for iPod & Apple TV (5.7 MB, 3:41)
#22
Apr 23

Eager Loading

One way to improve performance is to cut down on the number of SQL queries. You can do this through eager loading. Learn all about it in this episode!
Download (22.7 MB, 4:37)
alternative download for iPod & Apple TV (9.7 MB, 4:37)
#23
Apr 25

Counter Cache Column

If you need to display the record count for a has_many association, you can improve performance by caching that number in a column.
Download (18.8 MB, 7:18)
alternative download for iPod & Apple TV (10.7 MB, 7:18)
#25
Apr 30

SQL Injection

One of the most common security problems for dynamic sites is SQL Injection. Thankfully Rails does everything it can in solving this issue, but you still need to be aware of it.
Download (16.3 MB, 5:29)
alternative download for iPod & Apple TV (8.7 MB, 5:29)
#26
May 02

Hackers Love Mass Assignment

Your site may be at risk! When using mass assignment, you are giving the user complete control over that model and its associations. See how a hacker might use this vulnerability and learn how to stop it in this episode.
Download (15.2 MB, 6:14)
alternative download for iPod & Apple TV (8.9 MB, 6:14)
#32
May 16

Time in Text Field

Although Rails does allow you to edit time attributes with text fields, it's not very flexible. In this episode you will learn how to use a virtual attribute to format the time to your liking.
Download (15.1 MB, 5:22)
alternative download for iPod & Apple TV (8 MB, 5:22)
#33
May 18

Making a Plugin

You can sometimes remove a lot of duplication by generating methods dynamic. In this episode I will show you how to create a plugin which does exactly that.
Download (22.2 MB, 7:55)
alternative download for iPod & Apple TV (12.3 MB, 7:55)
#41
Jun 06

Conditional Validations

By default, validations will take place every time the model is saved. Sometimes you only want a validation to happen when certain conditions are met. See how to do that in this episode.
Download (8.6 MB, 4:59)
alternative download for iPod & Apple TV (6.1 MB, 4:59)
#47
Jun 20

Two Many-to-Many

There are two different ways to set up a many-to-many association in Rails. In this episode you will see how to implement both ways along with some tips on choosing the right one for your project.
Download (17 MB, 9:00)
alternative download for iPod & Apple TV (11.1 MB, 9:00)
#57
Jul 13

Create Model Through Text Field

Let's say you provide a select menu for setting which category a given product belongs to, but you also want the option of creating a new category by typing the name in a text field. See a great way to do that in this episode.
Download (12.7 MB, 5:30)
alternative download for iPod & Apple TV (7.4 MB, 5:30)
#59
Jul 18

Optimistic Locking

When two people attempt to update the same record near the same time, one of the updates will likely be overwritten. You can solve this problem with optimistic locking.
Download (16.4 MB, 7:26)
alternative download for iPod & Apple TV (10.4 MB, 7:26)
#62
Jul 25

Hacking ActiveRecord

Have you ever wanted to temporarily disable all validations? Well, ActiveRecord doesn't support this, but that doesn't mean we can't add it. This episode will show you how to open up an existing class and change its behavior.
Download (23.9 MB, 11:13)
alternative download for iPod & Apple TV (15.5 MB, 11:13)
#63
Jul 27

Model Name in URL

By default, Rails uses the model's id in the URL. What if you want to use the name of the model instead? You can change this behavior by overriding the to_param method in the model. Watch this episode for details.
Download (10.8 MB, 6:07)
alternative download for iPod & Apple TV (7.9 MB, 6:07)
#91
Feb 04

Refactoring Long Methods

In this episode I walk you through an exercise in refactoring by taking a long method and making it more concise.
Download (12.9 MB, 7:29)
alternative download for iPod & Apple TV (9.7 MB, 7:29)
#103
Apr 28

Site Wide Announcements

Sometimes you need to display an administrative announcement to every page on the site and give the users the ability to hide the announcement. See how in this episode.
Download (21.5 MB, 13:30)
alternative download for iPod & Apple TV (16.2 MB, 13:30)
#108
May 19

named_scope

The named_scope method in Rails 2.1 makes performing finds on models very elegant and convenient. See how in this episode.
Download (12.5 MB, 11:02)
alternative download for iPod & Apple TV (12.1 MB, 11:02)
#109
May 21

Tracking Attribute Changes

Rails 2.1 keeps track of the changes you make to a model's attributes. It also allows you to see what the previous value was. But watch out for the gotcha! See this episode for details.
Download (8.1 MB, 7:26)
alternative download for iPod & Apple TV (7.9 MB, 7:26)
subscribe:
sponsored by:
if you want to help:
required:
Get Quicktime Player