Skip to content

Instantly share code, notes, and snippets.

@torkale
Created April 24, 2012 06:18
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 torkale/2477049 to your computer and use it in GitHub Desktop.
Save torkale/2477049 to your computer and use it in GitHub Desktop.
repeating singleton methods
class User < ActiveRecord::Base
STATUS = { :active => 1, :inactive => 2, :pending => 3, :announce => 4, :curator => 5 }
def self.active; where(:status => STATUS[:active]); end
def self.inactive; where(:status => STATUS[:inactive]); end
def self.pending; where(:status => STATUS[:pending]); end
def self.announce; where(:status => STATUS[:announce]); end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment