blob: aff830abfaadef7cadaea47a82e3b9c644af15b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# frozen_string_literal: true
class Posts::VotesController < ApplicationController
before_action :load_post
before_action :load_user
before_action :check_auth
def destroy
engine = Booru::VotingEngine.new(@user, @post)
engine.unvote!
@post.update_index
redirect_to short_post_path(@post)
end
private
def load_post
@post = Post.find(params[:post_id])
end
def load_user
@user = User.find(params[:id])
end
def check_auth
authorize! :tamper_votes, @post
end
end
|