Class: Admin::InvalidMessageComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Admin::InvalidMessageComponent
- Defined in:
- lib/generators/infold/templates/install/app/components/admin/invalid_message_component.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(form, field) ⇒ InvalidMessageComponent
constructor
A new instance of InvalidMessageComponent.
- #render? ⇒ Boolean
Constructor Details
#initialize(form, field) ⇒ InvalidMessageComponent
Returns a new instance of InvalidMessageComponent.
5 6 7 |
# File 'lib/generators/infold/templates/install/app/components/admin/invalid_message_component.rb', line 5 def initialize(form, field) @message = form.object.errors.(field)&.first end |
Instance Method Details
#call ⇒ Object
13 14 15 |
# File 'lib/generators/infold/templates/install/app/components/admin/invalid_message_component.rb', line 13 def call "<div class=\"invalid_message\">#{@message}</div>".html_safe end |
#render? ⇒ Boolean
9 10 11 |
# File 'lib/generators/infold/templates/install/app/components/admin/invalid_message_component.rb', line 9 def render? @message.present? end |