Friday, September 20, 2024 12:05:59 AM
> settings

Customize


Authenticate

> uploaded_file.rb
# 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
All opinions represented herein are my own
- © 2024 itsthedevman
- build 3c15a1b