Monday, December 4th, 2006

Active Record Extension – Ryan’s Scraps



Read a useful posting on Ryan’s scraps about how to extend ActiveRecord.

class Organization < ActiveRecord::Base
  has_many :people do
    def find_active
      find(:all, :conditions => ["active = ?", true])
    end
  end
end

This simply adds the ability to find_active

organization.people.find_active

blog comments powered by Disqus