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.
28 lines
776 B
Ruby
28 lines
776 B
Ruby
class ForumPostVotesController < ApplicationController
|
|
respond_to :html, :xml, :json, :js
|
|
before_action :member_only, only: [:create, :destroy]
|
|
|
|
def index
|
|
@forum_post_votes = ForumPostVote.includes(creator: [], forum_post: [:topic]).paginated_search(params, count_pages: true)
|
|
respond_with(@forum_post_votes)
|
|
end
|
|
|
|
def create
|
|
@forum_post = ForumPost.find(params[:forum_post_id])
|
|
@forum_post_vote = @forum_post.votes.create(forum_post_vote_params)
|
|
respond_with(@forum_post_vote)
|
|
end
|
|
|
|
def destroy
|
|
@forum_post_vote = CurrentUser.user.forum_post_votes.find(params[:id])
|
|
@forum_post_vote.destroy
|
|
respond_with(@forum_post_vote)
|
|
end
|
|
|
|
private
|
|
|
|
def forum_post_vote_params
|
|
params.fetch(:forum_post_vote, {}).permit(:score)
|
|
end
|
|
end
|