Last active
December 15, 2015 10:49
-
-
Save invalidusrname/5248634 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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