Question

I have some environment variables defined in .powenv.

export FOO=bar

A method that runs asynchronously via delayed_job needs to access this environment variable:

class A < ActiveRecord::Base
  def my_method
    B.new
  end
end
handle_asynchronously :my_method

class B
  def initialize
   puts ENV['FOO']
  end
end

a = A.find(1)
a.my_method

Is ENV['FOO'] available when my_method is called delayed?

Was it helpful?

Solution

I figured it out. Just run:

. .powenv
script/console delayed_job start

This answer led me to the right track: Environment variable in Rails console and Pow

If you want to know what the dot command is for: https://superuser.com/questions/46139/what-does-source-do

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top