# frozen_string_literal: true class UploadedFile < ApplicationRecord include PublicIdConcern self.table_name = "files" ########################################### # Attributes attribute :public_id, :public_id attribute :file_name, :string attribute :file_type, :string attribute :created_at, :datetime attribute :updated_at, :datetime has_one_attached :data ########################################### # Associations has_one :post_file, dependent: :destroy, foreign_key: :file_id, inverse_of: :file has_one :post, through: :post_file ########################################### # Validations validates :file_name, :file_type, :data, presence: true end