1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 23:59:40 +02:00
Maybe/app/models/transaction.rb
Dave Corson-Knowles e5750d1a13
Add presence validations for required fields (#545)
* Adds basic validations for required fields

Also deletes a few extraneous .keep files

Does not add the family_id required field for user, since that breaks the basic test setup

* Restore keep files to this branch

* Remove Credit model and validate models behind ids

* Restore concerns .keep
2024-03-15 15:21:59 -04:00

22 lines
437 B
Ruby

class Transaction < ApplicationRecord
belongs_to :account
belongs_to :category, optional: true
validates :name, :date, :amount, :account, presence: true
after_commit :sync_account
def self.ransackable_attributes(auth_object = nil)
%w[name amount date]
end
def self.ransackable_associations(auth_object = nil)
%w[category account]
end
private
def sync_account
self.account.sync_later
end
end