Man, the answer was simple.
I just changed it to this:
task :load_devise_key do
if Rails.env.production?
fn = ".env-production"
else
fn = ".env"
end
puts "Trying to read devise secret key from #{fn}"
match = File.read(fn).match /DEVISE_SECRET_KEY='(.*)'/
puts File.read(fn)
if match
Devise.secret_key = match[1]
ENV['DEVISE_SECRET_KEY'] = match[1]
puts "Found devise secret key"
else
puts "Couldn't find secret key"
end
end
task :environment => :load_devise_key
Seems to have done the trick!