I’m using foreman along with a .env file for storing all my config vars. However, whenever I try to access them in a rake task they always come up blank. Here’s a basic example of what I’m trying to do:
task :send_to_twitter => :environment do @twit = Twitter::REST::Client.new do |config| config.consumer_key = ENV['TWITTER_KEY'] config.consumer_secret = ENV['TWITTER_SECRET'] config.access_token = ENV['TWITTER_ACCESS_TOKEN'] config.access_token_secret = ENV['TWITTER_SECRET_ACCESS_TOKEN'] end @twit.update "I'm tweeting via a rake task!" end
None of the ENV variables above work, and I imagine I’m going to run into the same problem when I deploy to Heroku. Any ideas on how I can use the ENV vars in this rake task?