# frozen_string_literal: true class Posts::DescriptionLocksController < ApplicationController before_action :load_post before_action :check_auth def create @post.update(description_editing_allowed: false) flash[:notice] = t('posts.toggle_description_lock.locked') # HidableLogger.log(@post, 'Description editing locked', current_user.name) redirect_to short_post_path(@post) end def destroy @post.update(description_editing_allowed: true) flash[:notice] = t('posts.toggle_description_lock.unlocked') redirect_to short_post_path(@post) end private def load_post @post = Post.find(params[:post_id]) end def check_auth authorize! :manage, @post end end