Skip to content

Instantly share code, notes, and snippets.

@jackdempsey
Created August 3, 2011 23:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jackdempsey/1124182 to your computer and use it in GitHub Desktop.
Save jackdempsey/1124182 to your computer and use it in GitHub Desktop.
class Foo < ActiveRecord::Base
include Models::Scopes::Order
default_scope recently_updated # didn't realize you could do this
end
module Models
module Scopes
module Order
extend ActiveSupport::Concern
included do
scope :recently_created, order('created_at DESC')
scope :recently_updated, order('updated_at DESC')
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment