2025-01-17 18:05:42 +08:00
|
|
|
|
class WeatherArt < ApplicationRecord
|
2025-01-18 21:42:31 +08:00
|
|
|
|
belongs_to :city
|
|
|
|
|
|
|
|
|
|
has_one_attached :image
|
|
|
|
|
|
|
|
|
|
scope :latest, -> { order(created_at: :desc) }
|
|
|
|
|
|
|
|
|
|
def image_url
|
|
|
|
|
# 这里实现获取图片URL的逻辑,可以是AWS S3或其他存储服务
|
|
|
|
|
Rails.application.routes.url_helpers.rails_blob_path(image, only_path: true) if image.attached?
|
|
|
|
|
end
|
2025-01-17 18:05:42 +08:00
|
|
|
|
end
|