Pet Project: Blog App (https://employmenthero.atlassian.net/wiki/spaces/GT/pages/3369402701/Pet+Project+Blog+App+-+Detailed+Guide)
- Clone this repo
- Open the console and run the below command.
bundle install
Run command
bundle exec rake db:create:all
bundle exec rake db:migrate
Sign Up
-
POST /api/users
-
Request body:
{
"user": {
"email": "[email protected]",
"password": "password",
"password_confirmation": "password"
}
}
sign-up.mov
Sign In
-
POST /api/users/sign_in
-
Request body:
{
"user": {
"email": "[email protected]",
"password": "password"
}
}
sign-in.mov
Create a Blog (Authenticated)
-
POST /api/blogs
-
Request body:
{
"blog": {
"title": "Blog Post Title",
"content": "This is the content of the blog post."
}
}
create_blog_edit.mov
Get All Blogs
-
GET /api/blogs
-
Response:
{
data: [
{
"id": 1,
"title": "Blog Post Title",
"content": "This is the content of the blog post.",
"user_id": 1,
"created_at": "2025-01-01T00:00:00Z",
"updated_at": "2025-01-01T00:00:00Z"
}
]
}
get_all_blogs.mov
Get a Specific Blog by ID
-
GET /api/blogs/:id
-
Response:
{
data: {
"id": 1,
"title": "Blog Post Title",
"content": "This is the content of the blog post.",
"user_id": 1,
"created_at": "2025-01-01T00:00:00Z",
"updated_at": "2025-01-01T00:00:00Z"
}
}
get_blog_id.mov
Update a Blog (Authenticated, own blog only)
-
PUT /api/blogs/:id
-
Request body:
{
"blog": {
"title": "Updated Blog Post Title",
"content": "This is the updated content of the blog post."
}
}
update_blog.mov
Delete a Blog (Authenticated, own blog only)
- DELETE /api/blogs/:id
delete_blog.mov
Create a Comment (Authenticated)
-
POST /api/blogs/:blog_id/comments
-
Request body:
{
"comment": {
"content": "This is a comment on the blog post."
}
}
create_comment.mov
Get All Comments for a Blog
-
GET /api/blogs/:blog_id/comments
-
Response:
{
data: [
{
"id": 1,
"content": "This is a comment on the blog post.",
"user_id": 1,
"blog_id": 1,
"created_at": "2025-01-01T00:00:00Z",
"updated_at": "2025-01-01T00:00:00Z"
}
]
}
get_all_comments.mov
bundle exec rspec