Rails API blog lab

Instructions

Clone this repo:

  • git@github.com:ga-wdi-boston/wdi_7_rails_lab_rails_api_blog.git

Create a new Rails API application in this directory

  • rails-api new . blogAPILab --database=postgresql -T

Scaffold Posts and Comments

  • rails g scaffold Post title body:text
  • rails g scaffold Comment content post:belongs_to

Setup associations between Posts and Comments in the models

Create a new Heroku app and push to Heroku

  • git add .
  • git commit -m "Created new app with posts and comments"
  • heroku create
  • git push heroku master
  • heroku run rake db:migrate
  • heroku open

Watch the Railscast on Rails API. Read the rails-api documentation.

Setup routes and controller so that comments are nested under posts.

Read on Active Model Serializers. Watch the Railscast on Active Model Serializers.