Module: DryCrud::GenericModel::ClassMethods
- Defined in:
- app/controllers/dry_crud/generic_model.rb
Overview
Class methods from GenericModel.
Instance Method Summary collapse
-
#model_class ⇒ Object
The ActiveRecord class of the model.
-
#model_identifier ⇒ Object
The identifier of the model used for form parameters.
-
#models_label(plural: true) ⇒ Object
A human readable plural name of the model.
Instance Method Details
#model_class ⇒ Object
The ActiveRecord class of the model.
59 60 61 |
# File 'app/controllers/dry_crud/generic_model.rb', line 59 def model_class @model_class ||= controller_name.classify.constantize end |
#model_identifier ⇒ Object
The identifier of the model used for form parameters. I.e., the symbol of the underscored model name.
65 66 67 |
# File 'app/controllers/dry_crud/generic_model.rb', line 65 def model_identifier @model_identifier ||= model_class.model_name.param_key end |
#models_label(plural: true) ⇒ Object
A human readable plural name of the model.
70 71 72 73 74 75 76 |
# File 'app/controllers/dry_crud/generic_model.rb', line 70 def models_label(plural: true) opts = { count: (plural ? 3 : 1) } opts[:default] = model_class.model_name.human.titleize opts[:default] = opts[:default].pluralize if plural model_class.model_name.human(opts) end |