summaryrefslogtreecommitdiffhomepage
path: root/app/controllers/api
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2024-04-08 21:58:55 -0400
committerrealtradam <[email protected]>2024-04-08 21:58:55 -0400
commit5d6c31ab4b3b6b663485021c697a41e2a2531b9c (patch)
tree47a9ba9933f5c73d617d106fecce6891316d1e5d /app/controllers/api
parent05294b07c551c708b3bc51e2964ae01fcdfdd25f (diff)
downloadgameHolster-5d6c31ab4b3b6b663485021c697a41e2a2531b9c.tar.gz
gameHolster-5d6c31ab4b3b6b663485021c697a41e2a2531b9c.zip
add blog index
Diffstat (limited to 'app/controllers/api')
-rw-r--r--app/controllers/api/v1/blog_controller.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/controllers/api/v1/blog_controller.rb b/app/controllers/api/v1/blog_controller.rb
new file mode 100644
index 0000000..4594645
--- /dev/null
+++ b/app/controllers/api/v1/blog_controller.rb
@@ -0,0 +1,29 @@
+class Api::V1::BlogController < ApplicationController
+ before_action :set_blog, only: %i[show destroy]
+
+ def index
+ blog = Blog.all.order(created_at: :desc)
+ render json: blog
+ end
+
+ def create
+ blog = Blog.Create!(blog_params)
+ if blog
+ render json: blog
+ else
+ render json: blog.errors
+ end
+ end
+
+ def show
+ end
+
+ def destroy
+ end
+
+ private
+
+ def blog_params
+ params.permit(:name, :image, :content, :category, :live_date, :update_date)
+ end
+end