0

I'm trying to push a new app to Heroku, it has devise preinstalled locally. Once i try to hit the git push heroku master, every time it tells me 'Devise.secret_key was not set. Please add the following to your Devise initializer:' Now they key .. comes different everytime, so setting it in initializers/devise.rb had no effect what so ever. I've tried setting it in heroku under the vars, but the same, the key keeps changing

I'm using Rails 5.0 with devise 4.2.

Any idea idea on how to run it without it changing every single time ? or how to set it ?

*I've browsed stackoverflow for the past 2 hours and saw no solution to my question.

Thank you.

alex lug
  • 183
  • 1
  • 12
  • Maybe you can find some new approaches here? https://stackoverflow.com/questions/18080910/devise-secret-key-was-not-set – Clara Apr 10 '20 at 16:19
  • I have tried all of those approaches, none of them fixes the problem. I also don't understand why devise 'has to' continously update that key, something that on DO, aws or local does not happen – alex lug Apr 10 '20 at 18:28
  • What do you mean bu that: `Now they key .. comes different everytime,` ? – Clara Apr 10 '20 at 20:03

1 Answers1

0

Set SECRET_KEY_BASE through heroku dashboard or through cli - heroku config:set SECRET_KEY_BASE=<some-key-here>. Execute rake secret to get one.

Yurii
  • 682
  • 4
  • 8
  • Same problem. did it in the following order : "rake secret", got the key, set it with "heroku config:set SECRET_KEY_BASE= ", did 'git push heroku master'. The exact same problem, devise initiaties a new key every time. Any other tips ? – alex lug Apr 10 '20 at 10:06
  • Try to specify explicitly `config.secret_key = ENV['SECRET_KEY_BASE']` in `initializers/devise.rb` – Yurii Apr 11 '20 at 05:33
  • i tried that Yurii. sorry for replying late. It did not work, devise simply generates something every single time – alex lug Apr 13 '20 at 19:50
  • Hmm... Do you have ability to share current setup? – Yurii Apr 14 '20 at 05:40
  • No i do not, it's quite easy - i had a SECRET_KEY_BASE set in the server envs, which i also copied as the config.secret_key in devise's rb. But everytime i ran a deploy, devise was generating a new key telling me to put that instead. So the simple question is .. how to avoid that ? – alex lug Apr 15 '20 at 17:24