Moved the functions into a module and the problem gone.
namespace :backtest do
Module MY
def self.get_user_input
if ENV['date_from'].present? && ENV['date_until'].present?
# get input...
else
abort 'Sample usage: blah blah...'
end
end
end
desc "Start backtest"
task :start => :environment do
My.get_user_input
# rest of the code...
end
end