Last active
March 1, 2016 20:01
-
-
Save taylor/10000885 to your computer and use it in GitHub Desktop.
initializers/devise.rb change for to support Devise secret_key as an environment variable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb | |
| index cbe1fbd..358f9c3 100644 | |
| --- a/config/initializers/devise.rb | |
| +++ b/config/initializers/devise.rb | |
| @@ -5,6 +5,11 @@ Devise.setup do |config| | |
| # random tokens. Changing this key will render invalid all existing | |
| # confirmation, reset password and unlock tokens in the database. | |
| # config.secret_key = '13844ee05eb483442eef5ace6cd3a7ba60cf65bf0165dad57ed09150e6a1cb62913ca593bd68debb6235e79f04e5c587c | |
| + if Rails.env.production? | |
| + config.secret_key = ENV['DEVISE_SECRET_KEY'] | |
| + else | |
| + config.secret_key = 'x' * 128 | |
| + end | |
| # ==> Mailer Configuration | |
| # Configure the e-mail address which will be shown in Devise::Mailer |
Author
You can improve the code: config.secret_key = ENV['DEVISE_SECRET_KEY'] if Rails.env.production?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was to deal with a deploy to heroku complaining about Devise secret key:
After updating the code to use the environment variable (DEVISE_SECRET_KEY) run
heroku config:set DEVISE_SECRET_KEY=xxx --app blahYou can get a key by running
rake secret