# frozen_string_literal: true # Dotations class Dotation < ApplicationRecord # == Constants ============================================================ # == Attributes =========================================================== # == Extensions =========================================================== # == Relationships ======================================================== belongs_to :expert, optional: true belongs_to :partner belongs_to :min_amount_curr, foreign_key: :min_amount_curr_id, class_name: 'Currency' belongs_to :max_amount_curr, foreign_key: :max_amount_curr_id, class_name: 'Currency' has_and_belongs_to_many :expenses has_and_belongs_to_many :company_sizes has_and_belongs_to_many :projects has_and_belongs_to_many :tags has_and_belongs_to_many :company_activities # == Validations ========================================================== validates :name, presence: true validates :formal_name, presence: true # == Scopes =============================================================== scope :search, (lambda do |search_value| where('name LIKE :value OR formal_name LIKE :value', value: "%#{search_value}%") end) # == Callbacks ============================================================ # == Class Methods ======================================================== # == Instance Methods ===================================================== end