Fix an `undefined method post_vote_url` exception when doing `POST https://danbooru.donmai.us/posts/1/votes.json`. Also add the following API endpoints: * https://danbooru.donmai.us/post_votes/:id.json * https://danbooru.donmai.us/comment_votes/:id.json * https://danbooru.donmai.us/forum_post_votes/:id.json where `:id` is the vote ID, not the post ID.
29 lines
935 B
Ruby
29 lines
935 B
Ruby
class ForumPostVotesController < ApplicationController
|
|
respond_to :html, :xml, :json, :js
|
|
|
|
def index
|
|
@forum_post_votes = authorize ForumPostVote.visible(CurrentUser.user).paginated_search(params, count_pages: true)
|
|
@forum_post_votes = @forum_post_votes.includes(:creator, forum_post: [:creator, :topic]) if request.format.html?
|
|
|
|
respond_with(@forum_post_votes)
|
|
end
|
|
|
|
def show
|
|
@forum_post_vote = authorize ForumPostVote.find(params[:id])
|
|
respond_with(@forum_post_vote)
|
|
end
|
|
|
|
def create
|
|
@forum_post = ForumPost.find(params[:forum_post_id])
|
|
@forum_post_vote = authorize ForumPostVote.new(creator: CurrentUser.user, forum_post: @forum_post, **permitted_attributes(ForumPostVote))
|
|
@forum_post_vote.save
|
|
respond_with(@forum_post_vote)
|
|
end
|
|
|
|
def destroy
|
|
@forum_post_vote = authorize ForumPostVote.find(params[:id])
|
|
@forum_post_vote.destroy
|
|
respond_with(@forum_post_vote)
|
|
end
|
|
end
|