开发者

How to know which rails environment is running in delayed job

开发者 https://www.devze.com 2023-03-24 23:43 出处:网络
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?

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号