I'm trying to find out a simple way for my task rake to locate users in the DB that have 0 days left from their created_at. Now so far I've been playing around with this, works great for single user but I want each user to be checked, if one or many are found with 0 days left... do something. Here's what I've got so far.
task :check_trial => :environment do
def remaining_days
users = User.all
users.each do |user|
((user.created_at + 30.days).to_date - Date.today).round
end
end
if remaining_days <= 0
redirect_to http://www.google.com
end
end
Not the cleanest, but either way the above isn't working for me. I'm not getting here something about the User.all. Anyone, please do assist and thank you in advance