# frozen_string_literal: true class Posts::FeaturesController < ApplicationController before_action :load_post before_action :check_auth def create tag = Tag.find_tag_by_name('featured image') @post.features.create!(user: current_user) @post.add_tags [tag] @post.save! TagChange.create!(request_attributes.merge(added: true, post: @post, tag: tag)) flash[:notice] = t('posts.feature.success') redirect_to short_post_path(@post) end private def load_post @post = Post.find_by!(id: params[:post_id], hidden_from_users: false) end def check_auth authorize! :feature, @post end end