Class: Infold::Model
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Infold::Model
- Defined in:
- app/models/infold/model.rb
Instance Method Summary collapse
- #locale_or_name ⇒ Object
- #name_pluralize ⇒ Object
- #self_and_association_models ⇒ Object
- #set_name_from_table_name ⇒ Object
Instance Method Details
#locale_or_name ⇒ Object
27 28 29 |
# File 'app/models/infold/model.rb', line 27 def locale_or_name locale.presence || name end |
#name_pluralize ⇒ Object
31 32 33 |
# File 'app/models/infold/model.rb', line 31 def name_pluralize name.to_s.underscore.pluralize end |
#self_and_association_models ⇒ Object
22 23 24 25 |
# File 'app/models/infold/model.rb', line 22 def self_and_association_models order = "CASE WHEN id = #{id} THEN 0 ELSE id END" self.class.where(id: [id] + child_model_associations.map(&:model_id)).order(Arel.sql(order)) end |
#set_name_from_table_name ⇒ Object
35 36 37 |
# File 'app/models/infold/model.rb', line 35 def set_name_from_table_name self.name = table_name&.singularize&.camelize end |