Files
danbooru/app/controllers/post_votes_controller.rb
evazion 2564e885c8 controllers: refactor only param includes.
Add extra includes needed by the `only` param inside `respond_with`.
2020-02-15 06:17:22 -06:00

28 lines
623 B
Ruby

class PostVotesController < ApplicationController
before_action :voter_only
skip_before_action :api_check
respond_to :js, :json, :xml, :html
rescue_with PostVote::Error, status: 422
def index
@post_votes = PostVote.paginated_search(params, count_pages: true)
@post_votes = @post_votes.includes(:user, post: :uploader) if request.format.html?
respond_with(@post_votes)
end
def create
@post = Post.find(params[:post_id])
@post.vote!(params[:score])
respond_with(@post)
end
def destroy
@post = Post.find(params[:post_id])
@post.unvote!
respond_with(@post)
end
end