stickers/backend/models/sticker.rb
2026-03-16 15:27:37 -07:00

24 lines
556 B
Ruby

class Sticker < ApplicationRecord
self.base_key = ENV['AIRTABLE_BASE_ID']
self.table_name = "tbl9kLyUrZNCJWf3L"
field :name, "Name"
field :active, "active"
field :autonumber, "id"
field :image_attachment, "image"
field :event_URL, "event_URL"
scope :only_active, -> { where(active: true) }
def as_json(options = nil)
{ id: autonumber, name: name, image: image, event_URL: event_url }
end
def event_url
url = event_URL
url.is_a?(String) ? url : url&.dig("url")
end
def image = image_attachment&.dig(0, "url")
end