我在.powenv中定义了一些环境变量。
export FOO=bar
通过delayed_job异步运行的方法需要访问此环境变量:
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
调用my_method时,ENV ['FOO']是否可用?
答案 0 :(得分:2)
我明白了。跑吧:
. .powenv
script/console delayed_job start
这个答案让我走上正轨: Environment variable in Rails console and Pow
如果您想知道dot命令的用途: https://superuser.com/questions/46139/what-does-source-do