File size: 666 Bytes
5010ad7 5d27770 5010ad7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 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
|