Skip to content

Instantly share code, notes, and snippets.

@invalidusrname
Last active December 15, 2015 10:49
Show Gist options
  • Save invalidusrname/5248634 to your computer and use it in GitHub Desktop.
Save invalidusrname/5248634 to your computer and use it in GitHub Desktop.
class User
def self.need_reminder(days_to_remind = 10, organization = nil)
reminder_date = expiration_date - days_to_remind
if organization
where("oranization_id = ? and expiration_date == ?", reminder_date, expiration_date)
else
where("expiration_date == ?", reminder_date)
end
end
class Orgnization
def self.users_needing_password_reminder
Users.need_reminder(days_to_remind, self)
end
end
class PasswordReminder
def self.remind_users
users = Organization.all.collect { o.users_needing_password_reminder }.compact
users.each do |user|
puts 'change yo password holmes'
end
end
PasswordReminder.remind_users
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment