Skip to content

Instantly share code, notes, and snippets.

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