Build-in rake tasks work fine, but my new custom one, in Project/lib/tasks/payments.rb doesn't get loaded:
namespace :payments do
desc "Tally payments at the end of the month"
task :compute => :environment do
BillingPeriod.compute_new_period
end
end
$ rake payments:compute
(in /Users/rob/Code/Apps/skyfarm)
rake aborted!
Don't know how to build task 'payments:compute'
It works fine if I load the file application.rb:
require 'lib/tasks/payments.rb'
...but it breaks other things:
$ rails s
./lib/tasks/payments.rb:1: undefined method `namespace' for main:Object (NoMethodError)
Change the file extension from .rb
to .rake
.