Skip to content

Instantly share code, notes, and snippets.

@torkale
Created April 24, 2012 06:20
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/2477080 to your computer and use it in GitHub Desktop.
Save torkale/2477080 to your computer and use it in GitHub Desktop.
DRY using define
class User < ActiveRecord::Base
STATUS = { :active => 1, :inactive => 2, :pending => 3, :announce => 4, :curator => 5 }
STATUS.each do |k, v|
define_singleton_method(k) do
where(:status => v)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment