Download app/controllers/posts_controller.rb from denise-oneill-inbox-ru/Rails-8-API-Image-Processing: direct link, hf CLI and curl.
- Browser
- Download file 666 Bytes
-
https://huggingface.co/spaces/denise-oneill-inbox-ru/Rails-8-API-Image-Processing/resolve/main/app/controllers/posts_controller.rb
- Command line
-
hf download hf://spaces/denise-oneill-inbox-ru/Rails-8-API-Image-Processing/app/controllers/posts_controller.rb
-
curl -L -o posts_controller.rb https://huggingface.co/spaces/denise-oneill-inbox-ru/Rails-8-API-Image-Processing/resolve/main/app/controllers/posts_controller.rb
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 | |