Class: Admin::InvalidMessageComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
lib/generators/infold/templates/install/app/components/admin/invalid_message_component.rb

Instance Method Summary collapse

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.full_messages_for(field)&.first
end

Instance Method Details

#callObject



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

Returns:

  • (Boolean)


9
10
11
# File 'lib/generators/infold/templates/install/app/components/admin/invalid_message_component.rb', line 9

def render?
  @message.present?
end