Class: Dsu::Views::Shared::ModelErrors
- Defined in:
- lib/dsu/views/shared/model_errors.rb
Constant Summary
Constants inherited from Message
Dsu::Views::Shared::Message::MESSAGE_TYPES
Instance Method Summary collapse
-
#initialize(model:, options: {}) ⇒ ModelErrors
constructor
A new instance of ModelErrors.
- #render ⇒ Object
Methods inherited from Message
Methods included from Support::ColorThemable
apply_theme, #prompt_with_options
Constructor Details
#initialize(model:, options: {}) ⇒ ModelErrors
Returns a new instance of ModelErrors.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/dsu/views/shared/model_errors.rb', line 9 def initialize(model:, options: {}) raise ArgumentError, 'model is nil' if model.nil? raise ArgumentError, "model is the wrong object type: \"#{model}\"" unless model.is_a?(ActiveModel::Model) # TODO: I18n. header = [:header] || 'The following ERRORS were encountered; changes could not be saved:' super(messages: model.errors., header: header, options: ) @model = model end |
Instance Method Details
#render ⇒ Object
20 21 22 23 24 |
# File 'lib/dsu/views/shared/model_errors.rb', line 20 def render return if model.valid? super end |