4

If I set up some environment variables in an application.yml file is there a way to access them inside a rake task? Doing env['VARIABLE_NAME'] doesn't work and neither does Rails.env['VARIABLE_NAME']

My rake task:

task :create_new_assignment => [:environment] do
   puts env['VARIABLE_NAME'] # => fails.
end
Cœur
  • 37,241
  • 25
  • 195
  • 267
TheWebs
  • 12,470
  • 30
  • 107
  • 211

1 Answers1

0

Just tested this, it works with ENV:

task :temp => :environment do
  puts ENV['i']
end

% rake temp i=5
5
Rustam Gasanov
  • 15,290
  • 8
  • 59
  • 72