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 Build a Rails API Namespacing Routes and JSON Checking our API with cURL

problems with simulating and questions about .json necessity

why do we have to specify .json in our request? is it because this tells the app what format of information the request wants? what if we didn't specify it? I can't seem to test this because I'm getting an error that tells me

Dereks-MacBook-Pro:NaomiFreeman_RailsAPI-f1ad3554f3896259b5e2baa9003d8d399b6f1362 DerekJLin$ curl localhost:3000/api/todo_lists
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
  <HEAD><TITLE>Internal Server Error</TITLE></HEAD>
  <BODY>
    <H1>Internal Server Error</H1>
    Missing `secret_key_base` for 'development' environment, set this value in `config/secrets.yml`
    <HR>
    <ADDRESS>
     WEBrick/1.3.1 (Ruby/2.3.3/2016-11-21) at
     localhost:3000
    </ADDRESS>
  </BODY>
</HTML>
Dereks-MacBook-Pro:NaomiFreeman_RailsAPI-f1ad3554f3896259b5e2baa9003d8d399b6f1362 DerekJLin$ curl http://localhost:3000/api/todo_lists
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
  <HEAD><TITLE>Internal Server Error</TITLE></HEAD>
  <BODY>
    <H1>Internal Server Error</H1>
    Missing `secret_key_base` for 'development' environment, set this value in `config/secrets.yml`
    <HR>
    <ADDRESS>
     WEBrick/1.3.1 (Ruby/2.3.3/2016-11-21) at
     localhost:3000
    </ADDRESS>
  </BODY>
</HTML>
Dereks-MacBook-Pro:NaomiFreeman_RailsAPI-f1ad3554f3896259b5e2baa9003d8d399b6f1362 DerekJLin$ curl http://localhost:3000/api/todo_lists.json
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
  <HEAD><TITLE>Internal Server Error</TITLE></HEAD>
  <BODY>
    <H1>Internal Server Error</H1>
    Missing `secret_key_base` for 'development' environment, set this value in `config/secrets.yml`
    <HR>
    <ADDRESS>
     WEBrick/1.3.1 (Ruby/2.3.3/2016-11-21) at
     localhost:3000
    </ADDRESS>
  </BODY>
</HTML>

1 Answer

Zachary Betz
Zachary Betz
10,413 Points

Hi Derek, judging from the error message (pasted below) in the code you posted, it looks like you need to add a key to your config/secrets.yml file.

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

To do this, follow the steps under "Setting up a Rails Application" in the Treehouse VM Installation Guide for Mac. http://treehouse.github.io/installation-guides/mac/treehouse-vm-mac.html