You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

28 lines
471 B

  1. class PostsController < ApplicationController
  2. before_action :set_post, only: [:good, :bad, :destroy]
  3. # POST /posts/:id/good
  4. def good
  5. @post.increment!(:good)
  6. head :no_content
  7. end
  8. # POST /posts/:id/bad
  9. def bad
  10. @post.increment!(:bad)
  11. head :no_content
  12. end
  13. # DELETE /posts/:id
  14. def destroy
  15. @post.update!(deleted_at: Time.current)
  16. head :no_content
  17. end
  18. private
  19. def set_post
  20. @post = Post.active.find(params[:id])
  21. end
  22. end