Skip to content

Instantly share code, notes, and snippets.

@ArionHardison
Created July 11, 2012 19:35
Show Gist options
  • Save ArionHardison/3092718 to your computer and use it in GitHub Desktop.
Save ArionHardison/3092718 to your computer and use it in GitHub Desktop.
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