This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -4,4 +4,12 @@ class Post < ApplicationRecord
|
||||
has_many :post_tags, dependent: :destroy
|
||||
has_many :tags, through: :post_tags
|
||||
has_many :user_post_views, dependent: :destroy
|
||||
has_one_attached :thumbnail
|
||||
|
||||
def as_json options = { }
|
||||
super(options).merge({ thumbnail: thumbnail.attached? ?
|
||||
Rails.application.routes.url_helpers.rails_blob_url(
|
||||
thumbnail, only_path: false) :
|
||||
nil })
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user