ActiveRecord Association Extensions

Today I want to address what I consider to be one of the most misused features of ActiveRecord. It is called ActiveRecord Association Extensions. How to Define An Association Extension Association Extensions lets you easily add functionality or alter exisiting functionality when dealing with ActiveRecord association. I will refer the following simple code in the […]

ActiveRecord default_scope

ActiveRecord, starting at v2.3.2, provides with a convenient way to perform default scoping on a model. This feature must be handled with extra thought before applying. Let’s look at the following class: class Post < ActiveRecord::Base default_scope where(:deleted_at => nil) end We’re going to use a nice trick here in order to display the actual […]