Take the 2-minute tour ×

I'm trying to set a rails environment variable in a separate yml file. and it looks like this:

  sap_url: "http://example.com/"

  show_evp: 'true'
  show_social_media: "true"

  show_evp: 'true'
  show_social_media: "true"

  show_evp: 'true'
  show_social_media: "true"

And in my rails admin I do the following

  config.model Settings do
    weight 1
    list do
      field :id
      field :show_hot_jobs
      if ENV['SHOW_EVP'] == 'true'
        field :show_evp
      field :show_students
      field :show_testimonials
      field :show_on_boarding

But the variable is always false, anyone have an idea of where I need to set these rails env variables or what is wrong with mine.

Kr, Vincent

share|improve this question
add comment

2 Answers

Use Figaro gem to handle ENV variables and private data. Simple and easy. You won't regret.

share|improve this answer
add comment
up vote 1 down vote accepted

Thanks for your help. I have created a .yml file in the config folder added all the settings that I need for dev / staging / prod.

Next in the lib folder created a module and did the following:

  def self.config
    OpenStruct.new \
    :url => yaml["url"]

and now I can use it via "ModuleName".config.url

Kr, Vince

share|improve this answer
add comment

Your Answer


