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

project files lead to Missing `secret_key_base` for 'development' environment, set this value in `config/secrets.yml`

Bah. Didn't know I had more text space when I wrote the first part.
Download project files, bundle, localhost produces this error. just fyi.

Denis Nurboja
Denis Nurboja
10,601 Points

Hi,

you have to generate new secret. Use 'rake secret' task to generate new secret.

Thanks for the reply, it turned out my YAML syntax was wrong as well as below.

2 Answers

alborz
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
alborz
Full Stack JavaScript Techdegree Graduate 30,885 Points

In case anyone else was wondering, the following solution helped me:

  1. Create a secrets.yml file in your config directory.

  2. In your terminal, type the following command: rake secret. This will generate a secret for you to include in your secrets.yml file.

  3. Add the following snippet of code to your config/secrets.yml file:

development:
  secret_key_base: PASTE_YOUR_GENERATED_SECRET_HERE

(NOTE: WHEN TYPING THE ABOVE COMMAND, BE SURE TO ADD SPACES BEFORE "secret_key_base" AND NOT TABS, AS THIS WON'T WORK IN A YML FILE.)

Be sure to migrate your database: bin/rake db:migrate RAILS_ENV=development

Now when you boot up the server and render the application in the browser, you should be good to go.

Daniel Kouba
Daniel Kouba
11,353 Points

This worked for me. I was in the new Rails API course as well. Thanks!

Thanks for this - worked fine for me! :-)

This is happening in the new Rails API course for me as well!

One thing to keep in mind, of course: if you're using actual, real keys for something you're really building, you have to make sure that these secrets don't get posted in public Git repos, etc. For our purposes, though, I believe it will be all right.