Created
July 11, 2012 19:35
-
-
Save ArionHardison/3092718 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
namespace :meal_plan do | |
desc "this job runs each morning and gives all the users their meals on their meal plans" | |
task :setup => :environment do | |
User.all.each do |u| | |
mp = u.meal_plans.first | |
mp.expires_at = DateTime.now.midnight | |
mp.save | |
mp.meal_times.each do |meal_time| | |
meal_time.meals.create | |
end | |
end | |
end | |
task :clean_up do | |
MealPlan.expired do | |
FoodDiaryEntry.create_from_expired_meal_plan | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment