blob: 15f789fd1e2d2e1127c1878dc09e00e2b446bb5e (
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::CommentLocksController < ApplicationController
before_action :load_post
before_action :check_auth
def create
@post.update(commenting_allowed: false)
flash[:notice] = t('posts.toggle_comments_lock.locked')
# HidableLogger.log(@post, 'Commenting locked', current_user.name)
redirect_to short_post_path(@post)
end
def destroy
@post.update(commenting_allowed: true)
flash[:notice] = t('posts.toggle_comments_lock.unlocked')
redirect_to short_post_path(@post)
end
private
def load_post
@post = Post.find(params[:image_id])
end
def check_auth
authorize! :manage, @post
end
end
|