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:
- The HTTP Verb and URL (ie 'GET '/dogs'')
- The rails controller action (ie 'dogs#index')
- The corresponding CRUD action (ie 'READ)
- The corresponding ActiveRecord method (ie 'all')
- Displays all of the projects
- Displays information about one project
- Displays a form to create a new project
- Creates a new project based on given parameters
- Displays a form to update an existing project
- Updates an existing project with given parameters
- 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 |