ファイル
btrc-hub/backend/app/representations/post_compact_repr.rb
T
2026-07-17 23:14:37 +09:00

27 行
464 B
Ruby

# frozen_string_literal: true
module PostCompactRepr
module_function
def base post
return nil if post.nil?
{
id: post.id,
title: post.title,
url: post.url,
thumbnail_url: thumbnail_url(post) }
end
def thumbnail_url post
return nil unless post.thumbnail.attached?
Rails.application.routes.url_helpers.rails_storage_proxy_url(
post.thumbnail,
only_path: false)
rescue
nil
end
end