Rails-8-API-Image-Processing / app /controllers /categories_controller.rb
denise-oneill-inbox-ru's picture
D8 staging from 92665ef4298ecff6735b080ff7901f2c19f719a7
5010ad7 verified
Raw History Blame Contribute Delete
516 Bytes
class CategoriesController < ApplicationController
before_action :authenticate_user!, only: []
def index
@pagy, @categories = pagy(Category.all)
end
def show
@category = Category.friendly.find(params[:slug])
authorize @category
posts = policy_scope(@category.posts).publicly_visible
.includes(:category, :tags, :user, :post_translations)
.order(published_at: :desc)
@pagy, @posts = pagy(posts)
end
end