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 The Rails Asset Pipeline and Styling Sass and Rails Add Image Assets and Remove Default Styling

Project download not working locally

hey,

I'm trying to set this project up locally. I've installed the project. Run

bundle

Then when I run a server I get this message in the browser: INTERNAL SERVER ERROR Missing secret_key_base for 'development' environment, set this value in config/secrets.yml

ANy help would be greatly appreciated.

1 Answer

Tim Knight
Tim Knight
28,888 Points

Hi Pete,

The secrets key is used as kind of an integrity checker with Rails. If you're generating the project on your own it'll make one for you, but if you're sharing a project this is a file that shouldn't be shared publicly so sometimes you'll see this error.

You can do a few things here.

  1. You could generate a new rails project on your system and then just copy the file config/secrets.yml into your treehouse project.

  2. Create a new config/secrets.yml file yourself in this project.

If you decide to create your own file, it's actually pretty easy. First just create a blank file at config/secrets.yml.

Next, you'll use YAML to format the file (not really that important if you're not familiar). Your file should look something like this.

development:
  secret_key_base: (add string here)

test:
  secret_key_base: (add string here)

production:
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

Now go to something like http://textmechanic.com/Random-String-Generator.html and just generate a random string of 128 characters in length and replace the "(add string here)" placeholders with two separate strings.

Thanks for your answer That was great. However now I have this issue:

(<unknown>): could not find expected ':' while scanning a simple key at line 3 column 1

Is it normal for rails projects to be a bit glitchy to setup?

Tim Knight
Tim Knight
28,888 Points

Not necessarily, but any time you're trying to get someone else's codebase working perfectly on your machine there can be adjustments in general regardless of your project.

It may be that you have a strange character in your random string that's freaking things out. This type of error usually comes from a syntax issue with yml files.

If you load up the terminal you can also use rake secret to generate a key.

Just got started back on this.

Thanks for your help Tim. Generating the key base from terminal worked great.