3

I am trying to push my project up to Heroku. I have been using:

    gem 'dotenv-rails', :groups => [:development, :test]

Because I am using recpatcha and need to export my keys to the app in development.

When I try to push the code to heroku I noticed this error message:

    remote:  !     NameError: uninitialized constant Dotenv

So I commented out the Dotenv gem and any Dotenv variables in the app. I ran

    $ bundle exec rake -P

Then tried the push again. I am still getting the same error from Heroku. Do I need to reset my gemfiles somehow?

Ryan Murphy
  • 842
  • 1
  • 9
  • 20
  • May be this will help you http://stackoverflow.com/a/23439259/2681997 – Ajay Barot Dec 08 '16 at 10:00
  • The thing is I have dotenv working fine, and I have set my heroku config with the keys, its just that when I push to heroku I get the uninitialized constant error. – Ryan Murphy Dec 08 '16 at 10:08
  • see this comment from above mentioned answer: http://stackoverflow.com/questions/23439148/set-secret-key-base-in-production-using-a-env-file/23439259#comment35939063_23439259 – Ajay Barot Dec 08 '16 at 10:26
  • I am not sure how to load dotenv into production using an init file, can you explain what is meant there? – Ryan Murphy Dec 08 '16 at 10:53
  • Ok. Into your `rails_project/cofig/ ` Create one file and named it `dotenv_load.rb` Into this new file paste this code `require 'dotenv' Dotenv.load`. Then find `secret_key_base` in your project. Copy the value of `secret_key_base` and paste this into `boot.rb` like this `ENV["SECRET_KEY_BASE"] = "YOUR SECRET KEY BASE"` – Ajay Barot Dec 08 '16 at 11:05

1 Answers1

6

Ok, so the answer in the end was that I needed to change

    gem 'dotenv-rails', :groups => [:development, :test]

to

    gem 'dotenv-rails', :require => 'dotenv/rails-now'

which I think is another way of doing what you were suggesting there @ABPrime. Thanks a lot for your help.

Ryan Murphy
  • 842
  • 1
  • 9
  • 20