Sha256: 6edea4cd0f40972181641a842eff487410c4a5b0af87d209e4036c7f9bccd22b

Contents?: true

Size: 1.01 KB

Versions: 34

Compression:

Stored size: 1.01 KB

Contents

require 'carrierwave/orm/activerecord'

module Tramway
  module Core
    class 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 }

      # 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
      end
      # FIXME detect inhertited locales
      def human_state_name
        I18n.t "activerecord.state_machines.tramway/core/application_record.state.states.#{state}"
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
tramway-core-1.8.1 app/models/tramway/core/application_record.rb
tramway-core-1.8 app/models/tramway/core/application_record.rb
tramway-core-1.7.4 app/models/tramway/core/application_record.rb
tramway-core-1.7.3 app/models/tramway/core/application_record.rb
tramway-core-1.7.2 app/models/tramway/core/application_record.rb
tramway-core-1.7.1 app/models/tramway/core/application_record.rb
tramway-core-1.7 app/models/tramway/core/application_record.rb
tramway-core-1.6.4 app/models/tramway/core/application_record.rb
tramway-core-1.6.3 app/models/tramway/core/application_record.rb
tramway-core-1.6.2 app/models/tramway/core/application_record.rb
tramway-core-1.6.1 app/models/tramway/core/application_record.rb
tramway-core-1.6 app/models/tramway/core/application_record.rb
tramway-core-1.5.5.2 app/models/tramway/core/application_record.rb
tramway-core-1.5.5.1 app/models/tramway/core/application_record.rb
tramway-core-1.5.5 app/models/tramway/core/application_record.rb
tramway-core-1.5.4 app/models/tramway/core/application_record.rb
tramway-core-1.5.3 app/models/tramway/core/application_record.rb
tramway-core-1.5.2 app/models/tramway/core/application_record.rb
tramway-core-1.5.1 app/models/tramway/core/application_record.rb
tramway-core-1.5 app/models/tramway/core/application_record.rb