diff options
Diffstat (limited to 'app/controllers/api/v1/blog_controller.rb')
| -rw-r--r-- | app/controllers/api/v1/blog_controller.rb | 29 |
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 |
