denise-oneill-inbox-ru's picture
Deploy Rails 8 Blog v1.0.0 from main 9acb6e4
5d27770 verified
Raw History Blame Contribute Delete
666 Bytes
class PostsController < ApplicationController
before_action :authenticate_user!, only: []
def index
posts = policy_scope(Post).publicly_visible
.includes(:category, :tags, :user, :post_translations)
.order(published_at: :desc)
@pagy, @posts = pagy(posts)
end
def show
@post = policy_scope(Post).publicly_visible.friendly.find(params[:slug])
authorize @post
@comments = @post.comments.includes(:user).order(created_at: :asc)
@current_reaction = @post.reactions.find_by(user: current_user) if user_signed_in?
impressionist(@post, nil, unique: [ :ip_address ])
end
end