# 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