Class: Tramway::Core::ApplicationRecord
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Tramway::Core::ApplicationRecord
- Extended by:
- Enumerize
- Includes:
- PgSearch::Model
- Defined in:
- app/models/tramway/core/application_record.rb
Class Method Summary collapse
- .file_extensions ⇒ Object
- .human_attribute_name(attribute_name, *_args) ⇒ Object
- .photo_versions ⇒ Object
- .search_by(*attributes, **associations) ⇒ Object
- .uploader(attribute_name, uploader_name, **options) ⇒ Object
Instance Method Summary collapse
- #creator ⇒ Object
-
#human_state_name ⇒ Object
FIXME: detect inhertited locales.
Class Method Details
.file_extensions ⇒ Object
57 58 59 |
# File 'app/models/tramway/core/application_record.rb', line 57 def file_extensions @extensions end |
.human_attribute_name(attribute_name, *_args) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'app/models/tramway/core/application_record.rb', line 34 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 |
.photo_versions ⇒ Object
53 54 55 |
# File 'app/models/tramway/core/application_record.rb', line 53 def photo_versions @versions end |
.search_by(*attributes, **associations) ⇒ Object
43 44 45 |
# File 'app/models/tramway/core/application_record.rb', line 43 def search_by(*attributes, **associations) pg_search_scope :full_text_search, against: attributes, associated_against: associations end |
.uploader(attribute_name, uploader_name, **options) ⇒ Object
47 48 49 50 51 |
# File 'app/models/tramway/core/application_record.rb', line 47 def uploader(attribute_name, uploader_name, **) mount_uploader attribute_name, "#{uploader_name.to_s.camelize}Uploader".constantize @versions = [:versions] if uploader_name == :photo @extensions = [:extensions] end |
Instance Method Details
#creator ⇒ Object
27 28 29 30 |
# File 'app/models/tramway/core/application_record.rb', line 27 def creator creation_event = audits.where(action: :create).first creation_event.user if creation_event.user_id.present? end |
#human_state_name ⇒ Object
FIXME: detect inhertited locales
63 64 65 |
# File 'app/models/tramway/core/application_record.rb', line 63 def human_state_name I18n.t "activerecord.state_machines.tramway/core/application_record.state.states.#{state}" end |