Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: How to set secret key for Devise in Rails?

I added the Devise gem then followed the instructions and ran rails generate devise:install, the result was the following:

/usr/local/rvm/gems/ruby-1.9.3-p194/gems/devise-3.2.4/lib/devise/rails/routes.rb:487:in        `raise_no_secret_key': Devise.secret_key was not set. Please add the following to your Devise initializer: (RuntimeError)

config.secret_key = 'abc123'

Please ensure you restarted your application after installing Devise or setting the key.

How do I 'restart' my application? And how and where do I set the secret key?

like image 384
Mike_Code_Novice Avatar asked May 15 '14 19:05

Mike_Code_Novice


Video Answer


1 Answers

In order to generate a secret run:

bundle exec rake secret

and copy the result from the console to the devise initializer (config/initializers/devise.rb)

config.secret_key = '4fce3c1c860216b8......'
like image 170
aloucas Avatar answered Oct 21 '22 07:10

aloucas