Skip to content

Instantly share code, notes, and snippets.

@chrisconley
Forked from mattm/gist:88488
Created April 1, 2009 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisconley/88674 to your computer and use it in GitHub Desktop.
Save chrisconley/88674 to your computer and use it in GitHub Desktop.
class Domain < ActiveRecord::Base
named_scope :length, lambda {|length| {:conditions => ["length = ?", length]} if !length.blank? || length == 'all'}
named_scope :viewable, lambda {{:conditions => ["viewable_at < ?", Time.now.utc]}}
named_scope :public, lambda {|public| {:conditions => ["public = ?", true]} if !public.blank?}
end
def self.search(options = {})
self.length(options[:length]).viewable.public(options[:public])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment