RailsCasts Pro episodes are now free!

Learn more or hide this

Applied Filters: Free Episodes xActive Record x
Hackers Love Mass Assignment
Episode #26May 02, 200767 comments

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. (6 minutes)
SQL Injection
Episode #25Apr 30, 200737 comments

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. (5 minutes)
Counter Cache Column
Episode #23Apr 25, 200769 comments

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. (7 minutes)
Eager Loading
Episode #22Apr 23, 200754 comments

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! (4 minutes)
Virtual Attributes
Episode #16Apr 09, 200765 comments

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. (3 minutes)
Fun with Find Conditions
Episode #15Apr 06, 200741 comments

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). (4 minutes)
Performing Calculations on Models
Episode #14Apr 04, 200735 comments

Performing Calculations on Models

Did you know ActiveRecord provides class methods for performing calculations on models? You can even use these methods through associations. (2 minutes)
Using with_scope
Episode #5Mar 14, 200757 comments

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! (2 minutes)
Move Find into Model
Episode #4Mar 12, 200746 comments

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. (2 minutes)
Find Through Association
Episode #3Mar 08, 200745 comments

Find Through Association

No need to pass foreign keys in find conditions, just do the find through a has_many association. (2 minutes)