ぼざクリ タグ広場 https://hub.nizika.monster
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

16 lines
646 B

  1. class Post < ApplicationRecord
  2. belongs_to :parent, class_name: 'Post', optional: true, foreign_key: 'parent_id'
  3. belongs_to :uploaded_user, class_name: 'User', optional: true
  4. has_many :post_tags, dependent: :destroy
  5. has_many :tags, through: :post_tags
  6. has_many :user_post_views, dependent: :destroy
  7. has_one_attached :thumbnail
  8. def as_json options = { }
  9. super(options).merge({ thumbnail: thumbnail.attached? ?
  10. Rails.application.routes.url_helpers.rails_blob_url(
  11. thumbnail, only_path: false) :
  12. nil })
  13. end
  14. end