Skip to content

Instantly share code, notes, and snippets.

@javan
Created April 8, 2009 20:06
Show Gist options
  • Save javan/91970 to your computer and use it in GitHub Desktop.
Save javan/91970 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
# These are all boolean fields defined for this User model.
# As we add more email columns, and add them to this array,
# the named_scope below keeps up.
EMAIL_COLUMNS = [:email_new_market_alerts, :email_new_announcements, :email_stock_notices]
named_scope :unsubscribed, lambda { { :conditions => EMAIL_COLUMNS.inject({}) { |conditions, column| conditions[column] = false; conditions } } }
end
# Find everyone who doesn't want any of our emails
User.unsubscribed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment