In this project, you will build routes that allow external users to Create, Read, Update, and Delete records in your database.
You can see a working example of how your application should function here.
First, head to the app/models
folder and look over the instance methods that are defined in each of the models. Compare them to the ones you defined in the photogram-queries
project. How similar or different was your implementation to mine? Ask questions on Piazza.
Don’t modify the methods; the automated tests rely on them being present and functional.
Build the following endpoints in the same way that we did in the msm-api
project. For each endpoint, simply render the result of one of the existing instance methods, converted to json using .to_json
.
For example:
/users
should show a list of all users.
For example:
/users/Galen
should show the details of one user.
For example:
/users/Galen/own_photos
should show a list of the user’s own photos.
For example:
/users/Galen/liked_photos
should show a list of the photos the user has liked.
For example:
/users/Galen/feed
should show a list of the photos posted by people the user is following.
For example:
/users/Galen/discover
should show a list of photos liked by the people the user is following.
For example:
/photos/628
should show the details of one photo.
For example:
/photos/628/likes
should show a list of the photo’s likes.
For example:
/photos/628/fans
should show a list of the photo’s fans.
For example,
/insert_like_record?input_photo_id=628&input_user_id=120
should add a record to the likes table.
Be sure to name the keys in the query string exactly input_photo_id
and input_user_id
.
For example:
/delete_like/4223
should delete a record from the likes table.
For example:
/photos/628/comments
should show a list of the photo’s comments.
For example,
/insert_comment_record?input_photo_id=628&input_user_id=120&input_body=An insightful comment
should add a record to the comments table.
Be sure to name the keys in the query string exactly input_photo_id
, input_user_id
, and input_body
.
For example:
/update_comment_record/4288?input_body=A better comment body
should update the comment.
Be sure to name the key in the query string exactly input_body
.