mirror of
https://github.com/System-End/stickers.git
synced 2026-04-19 20:55:13 +00:00
24 lines
556 B
Ruby
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
|