Module: DryCrud::GenericModel::ClassMethods

Defined in:
app/controllers/dry_crud/generic_model.rb

Overview

Class methods from GenericModel.

Instance Method Summary collapse

Instance Method Details

#model_classObject

The ActiveRecord class of the model.



62
63
64
# File 'app/controllers/dry_crud/generic_model.rb', line 62

def model_class
  @model_class ||= controller_name.classify.constantize
end

#model_identifierObject

The identifier of the model used for form parameters. I.e., the symbol of the underscored model name.



68
69
70
# File 'app/controllers/dry_crud/generic_model.rb', line 68

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.



73
74
75
76
77
78
79
# File 'app/controllers/dry_crud/generic_model.rb', line 73

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