* Add post/comment/forum vote counts to user profiles. * Show uploaders on post votes index and allow searching by uploader. * Show forum posters on forum votes index and allow searching by poster. * Add unvote link to forum votes index. * Only show unvote links to current user.
26 lines
551 B
Ruby
26 lines
551 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.includes(:user, post: [:uploader]).paginated_search(params)
|
|
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
|