# frozen_string_literal: true # == Schema Information # # Table name: badges # # id :integer not null, primary key # title :string not null # description :string not null # image :string # created_at :datetime not null # updated_at :datetime not null # disable_award :boolean default(FALSE), not null # priority :boolean default(FALSE) # class Badge < ApplicationRecord resourcify # Association has_many :badge_awards, dependent: :restrict_with_error has_many :users, through: :badge_awards validates :image, presence: true mount_uploader :image, AvatarUploader def as_json(*) { image_url: image.file&.url, title: title } end end