Normally we skip doing page counts on index pages when there aren't any search filters. This is on the assumption that most index pages have more than 1000 pages (20,000 results), so it's not worth counting them exactly. This isn't always true, so here we turn on full counts on certain index pages known to be small.
24 lines
668 B
Ruby
24 lines
668 B
Ruby
class CommentVotesController < ApplicationController
|
|
before_action :member_only
|
|
skip_before_action :api_check
|
|
respond_to :js, :json, :xml, :html
|
|
rescue_with CommentVote::Error, ActiveRecord::RecordInvalid, status: 422
|
|
|
|
def index
|
|
@comment_votes = CommentVote.includes(:user, comment: [:creator, :post]).paginated_search(params, count_pages: true)
|
|
respond_with(@comment_votes)
|
|
end
|
|
|
|
def create
|
|
@comment = Comment.find(params[:comment_id])
|
|
@comment_vote = @comment.vote!(params[:score])
|
|
respond_with(@comment)
|
|
end
|
|
|
|
def destroy
|
|
@comment = Comment.find(params[:comment_id])
|
|
@comment.unvote!
|
|
respond_with(@comment)
|
|
end
|
|
end
|