Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

No Secret Key Set

Dear Team:

In my console I receive the following error when generating devsise: :\Sites\projects\code\treebook>rails generate devise:install C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/devise-3.1.0/lib/devise/rai ls/routes.rb:445:in `raise_no_secret_key': Devise.secret_key was not set. Please add the following to your Devise initializer: (RuntimeError)

config.secret_key = '98ad5227d0f3d4167df975cdccd2b54372be727a2a81ba0dc4ceee9e7 8739e9a277e3be2832a2bd5ce0d9db96456d9118123c8e72a6b1b4bdbcb4942be805791'

What is the best way to handle this? I was also getting a lot of other output. I know this is not happening in the video. Maybe I should retrieve info from GitHub to add.

Thanks,

Chris

2 Answers

were your devise views working before now? or is this right after you installed the devise gem. If it was right after you installed devise I would just uninstall the devise gem then follow the instuctions in the videos again.

Stone:

Thank you!

What I did was uninstall the devise gem. Then reinstalled after installing bundle. I still get same basic error/ I am just unsure about how to install the secret key.

Chris

I handled this by adding the following lines to devise.rb file. You can find it in config/initializers/devise.rb

if Rails.env.production?
    config.secret_key = '98ad5227d0f3d4167df975cdccd2b54372be727a2a81ba0dc4ceee9e78739e9a277e3be2832a2bd5ce0d9db96456d9118123c8e72a6b1b4bdbcb4942be805791'   
end

P.S. I that's your secret key btw. I am not sure if that is good practice. It just worked for me, when uploading in heroku and when working in development.