add fiat balance
This commit is contained in:
28
app/models/fiat_balance.rb
Normal file
28
app/models/fiat_balance.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: fiat_balances
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# amount_cents :integer default(0), not null
|
||||
# amount_currency :string default("BRL"), not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# user_id :bigint not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_fiat_balances_on_user_id (user_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (user_id => users.id)
|
||||
#
|
||||
class FiatBalance < ApplicationRecord
|
||||
belongs_to :user
|
||||
|
||||
monetize :amount_cents
|
||||
|
||||
validates :amount, presence: true
|
||||
end
|
||||
@@ -26,6 +26,7 @@ class User < ApplicationRecord
|
||||
|
||||
has_many :documents, class_name: "UserDocument", dependent: :destroy
|
||||
has_many :balances, dependent: :restrict_with_error
|
||||
has_one :fiat_balance, dependent: :restrict_with_error
|
||||
|
||||
validates :first_name, :last_name, :email, presence: true
|
||||
validates :email, uniqueness: true
|
||||
|
||||
Reference in New Issue
Block a user