Sha256: 94a37eaea9ada9ff3a847cf9f1510d5c6d63a4ed6e3788df87ca57317527a6ca
Contents?: true
Size: 1.35 KB
Versions: 15
Compression:
Stored size: 1.35 KB
Contents
# frozen_string_literal: true require 'carrierwave/orm/activerecord' if defined?(CarrierWave::Mount) class Tramway::Core::ApplicationRecord < ActiveRecord::Base self.abstract_class = true audited extend ::Enumerize state_machine :state, initial: :active do state :active state :removed event :remove do transition active: :remove end end scope :active, -> { where state: :active } scope :created_by_user, lambda { |user_id| joins(:audits).where('audits.action = \'create\' AND audits.user_id = ?', user_id) } scope :admin_scope, ->(_arg) { all } include ::PgSearch::Model def creator audits.where(action: :create).first.user end # FIXME: detect inhertited locales class << self def human_attribute_name(attribute_name, *_args) excepted_attributes = %w[created_at updated_at state] if attribute_name.to_s.in? excepted_attributes I18n.t "activerecord.attributes.tramway/core/application_record.#{attribute_name}" else super attribute_name end end def search_by(*attributes, **associations) pg_search_scope :full_text_search, against: attributes, associated_against: associations end end # FIXME: detect inhertited locales def human_state_name I18n.t "activerecord.state_machines.tramway/core/application_record.state.states.#{state}" end end
Version data entries
15 entries across 15 versions & 1 rubygems