Class: Railsboot::ErrorsComponent
- Inherits:
-
Component
- Object
- Component
- Railsboot::ErrorsComponent
- Defined in:
- app/components/railsboot/errors_component.rb
Overview
ViewComponent: renders the errors block.
Instance Method Summary collapse
-
#error_messages ⇒ Array<String>
Flattened full error messages across all passed objects.
-
#errors ⇒ Array<ActiveModel::Errors>
Flattened errors across all passed objects.
-
#initialize(*objects, **html_attributes) ⇒ ErrorsComponent
constructor
A new instance of ErrorsComponent.
-
#render? ⇒ Boolean
Whether the component renders (only when error messages are present).
Constructor Details
#initialize(*objects, **html_attributes) ⇒ ErrorsComponent
Returns a new instance of ErrorsComponent.
7 8 9 10 |
# File 'app/components/railsboot/errors_component.rb', line 7 def initialize(*objects, **html_attributes) @objects = Array(objects) @html_attributes = html_attributes end |
Instance Method Details
#error_messages ⇒ Array<String>
Flattened full error messages across all passed objects
20 21 22 |
# File 'app/components/railsboot/errors_component.rb', line 20 def errors.map(&:full_messages).flatten end |
#errors ⇒ Array<ActiveModel::Errors>
Flattened errors across all passed objects
14 15 16 |
# File 'app/components/railsboot/errors_component.rb', line 14 def errors @objects.map(&:errors).flatten end |
#render? ⇒ Boolean
Whether the component renders (only when error messages are present)
26 27 28 |
# File 'app/components/railsboot/errors_component.rb', line 26 def render? .any? end |