How to know which rails environment is running in delayed job
I have a delayed job which is working perfectly fine. I want to know which environment is this. Is it production or development or staging. Check the code please. ENV["RAILS_ENV"] is nuil?
class SendMessageJob < Struct.n开发者_如何学Pythonew(:message_id)
def perform
p ENV["RAILS_ENV"] // printing nil :(
p "hello world"
end
end
I tried including
require "#{File.dirname(__FILE__)}/../config/environment.rb"
on the top the file still nothing..
You can try RAILS_ENV
(constant defined within Rails) or the newer one Rails.env
(a wrapper for this).
精彩评论