|
- class PostsController < ApplicationController
- before_action :set_post, only: [:good, :bad, :destroy]
-
- # POST /posts/:id/good
- def good
- @post.increment!(:good)
- head :no_content
- end
-
- # POST /posts/:id/bad
- def bad
- @post.increment!(:bad)
- head :no_content
- end
-
- # DELETE /posts/:id
- def destroy
- @post.update!(deleted_at: Time.current)
- head :no_content
- end
-
- private
-
- def set_post
- @post = Post.active.find(params[:id])
- end
- end
|