Class: Tramway::ApplicationRecord
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Tramway::ApplicationRecord
- Extended by:
- Enumerize
- Includes:
- AASM, PgSearch::Model
- Defined in:
- app/models/tramway/application_record.rb
Direct Known Subclasses
Class Method Summary collapse
- .file_extensions ⇒ Object
- .human_attribute_name(attribute_name, *_args) ⇒ Object
- .photo_versions ⇒ Object
- .search_by(*attributes, **associations) ⇒ Object
- .state_machines_names ⇒ Object
- .uploader(attribute_name, uploader_name, **options) ⇒ Object
Instance Method Summary collapse
Class Method Details
.file_extensions ⇒ Object
52 53 54 |
# File 'app/models/tramway/application_record.rb', line 52 def file_extensions @extensions end |
.human_attribute_name(attribute_name, *_args) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'app/models/tramway/application_record.rb', line 26 def human_attribute_name(attribute_name, *_args) excepted_attributes = %w[created_at updated_at] if attribute_name.to_s.in? excepted_attributes I18n.t "activerecord.attributes.tramway/application_record.#{attribute_name}" else super attribute_name end end |
.photo_versions ⇒ Object
48 49 50 |
# File 'app/models/tramway/application_record.rb', line 48 def photo_versions @versions end |
.search_by(*attributes, **associations) ⇒ Object
35 36 37 38 39 40 |
# File 'app/models/tramway/application_record.rb', line 35 def search_by(*attributes, **associations) pg_search_scope :full_text_search, against: attributes, associated_against: associations, using: %i[tsearch trigram] end |
.state_machines_names ⇒ Object
56 57 58 |
# File 'app/models/tramway/application_record.rb', line 56 def state_machines_names AASM::StateMachineStore.fetch(self).machine_names end |
.uploader(attribute_name, uploader_name, **options) ⇒ Object
42 43 44 45 46 |
# File 'app/models/tramway/application_record.rb', line 42 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
19 20 21 22 |
# File 'app/models/tramway/application_record.rb', line 19 def creator creation_event = audits.where(action: :create).first creation_event.user if creation_event.user_id.present? end |