1
2
3
4
5
6
7
8
9
10
11
12
13
# Invoke the command with the following (again at the command line in the root of your app: “rake defaults:set_targets”
# Don't forget to set account_id to 1 and admin? to true (1) in db
namespace :defaults do
  desc "set minimum targets for advisors with empty targets"
  task :set_targets => :environment do
    User.advisors.each do |advisor|
      advisor.categorical_years.each do |year|
        year.update_attribute(:target, 88500) if year.target.blank?
        year.update_attribute(:minimum_target, 33500) if year.minimum_target.blank?
      end
    end
  end  
end