Here's a gotcha that I came across today: don't define a constant as something in one Rails rake task file, and then define the same constant as something different in another file, because the last constant will supercede them all:
a.rake:
DATA = 'Hi there!'
desc "Test A"
task :test_a do
puts DATA
end
b.rake:
DATA = 'Hallo!'
desc "Test B"
task :test_b do
puts DATA
end
$ rake test_a
Hallo!
$ rake test_b
Hallo!
I guess this happens because Rake is loading all of the task files before running the requested task. There's probably a way to namespace the constant, but I need to do more research on that. In the meantime I'll use different constant names!