# frozen_string_literal: true # == Schema Information # # Table name: data_exports # # id :bigint not null, primary key # complete :boolean default(FALSE), not null # key :string # created_at :datetime not null # updated_at :datetime not null # user_id :integer not null # # Foreign Keys # # fk_rails_... (user_id => users.id) # class DataExport < ApplicationRecord belongs_to :user validates :key, presence: true before_validation :generate_key, on: :create private def generate_key self.key = SecureRandom.uuid end end