blob: 4a42fa6739201c67a167f3045de61b78c7bcd47b (
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
31
32
|
# frozen_string_literal: true
class Posts::RepairsController < ApplicationController
before_action :load_post
before_action :check_auth
def create
# HidableLogger.log(@post, 'Repair attempted', current_user.name)
if PostRepairer.new(@post).repair!
respond_to do |format|
format.html { redirect_to(post_path(@post), notice: t('posts.repair.success')) }
format.json { head :ok }
end
else
respond_to do |format|
format.html { redirect_to(post_path(@post), error: t('posts.repair.failure')) }
format.json { head :ok }
end
end
end
private
def load_post
@post = Post.find_by!(id: params[:post_id], destroyed_content: false)
end
def check_auth
authorize! :repair, @post
end
end
|