开发者

heroku plugin, how to access an env variable like RAILS_ENV?

开发者 https://www.devze.com 2023-03-29 07:05 出处:网络
I\'m in the process of building a rails plugin to automate my teams deployment process.. Problem is I can\'t find a way to access teh rails env variable. I have the following:

I'm in the process of building a rails plugin to automate my teams deployment process.. Problem is I can't find a way to access teh rails env variable. I have the following:

config = YAML.load(File.open("#{Dir.getwd}/config/s3.yml"))[RAILS_ENV]

That errors with:

in `cons开发者_运维技巧t_missing_from_s3_library': uninitialized constant Heroku::Command::Jammit::RAILS_ENV (NameError)

Anyone know how? Thanks


You should be using Rails.env instead of RAILS_ENV with Rails 3 and up. Try using:

config = YAML.load(File.open("#{Dir.getwd}/config/s3.yml"))[Rails.env]

Or this if you get scope issues with just Rails:

config = YAML.load(File.open("#{Dir.getwd}/config/s3.yml"))[::Rails.env]
0

精彩评论

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