# frozen_string_literal: true class Posts::FavoritesController < ApplicationController before_action :load_post before_action :check_auth def index respond_to do |format| format.html { render partial: 'posts/post_favoriters', locals: { post: @post } } format.json { render json: @post.faves.map(&:user_id) } end end private def load_post @post = Post.includes(faves: :user).find(params[:post_id]) end def check_auth authorize! :read, @post end end