RESTFUL challenge

Kickstarter

Welcome to Kickstarter. Assume we have a model called Project that inherits from ActiveRecord::Base, a corresponding table called projects, and a controller called ProjectsController that inherits from ApplicationController

For each of the following descriptions, write out the corresponding:

  1. The HTTP Verb and URL (ie 'GET '/dogs'')
  2. The rails controller action (ie 'dogs#index')
  3. The corresponding CRUD action (ie 'READ)
  4. The corresponding ActiveRecord method (ie 'all')

Actions

  1. Displays all of the projects
  2. Displays information about one project
  3. Displays a form to create a new project
  4. Creates a new project based on given parameters
  5. Displays a form to update an existing project
  6. Updates an existing project with given parameters
  7. Deletes an existing project

HTTP URI Route / Controller Action CRUD SQL AR Method
POST /projects #create CREATE INSERT INTO projects (column1, column2) VALUES (value1, value2) Project.create OR .new + .save conditional
GET /projects #index READ SELECT * FROM projects Project.all
GET /projects/:id #show READ SELECT * FROM projects WHERE id = :id LIMIT 1 Project.find(params[:id])
GET /projects/:id/edit #edit READ SELECT * FROM projects WHERE id = :id LIMIT 1 Project.find(params[:id])
GET /projects/new #new READ Project.new
PATCH /projects/:id #update UPDATE UPDATE projects SET column1 = value1, column2 = value2 WHERE id = :id Project.update
DELETE /projects/:id #destroy DELETE DELETE FROM projects WHERE id = :id Project.find(params[:id]).destroy