Monthly Archives: August 2013

Reusing ActiveRecord scopes

You can use an ActiveRecord scope from one model to scope queries on another that joins it. This can be very convenient and keep your scopes DRY. class Post < ActiveRecord::Base belongs_to :user scope :recent, lambda { order(:updated_at).last(10) } end class … Continue reading

Posted in Uncategorized | Leave a comment