Module: ActionView::Helpers::FormHelper

Defined in:
lib/optimism.rb

Instance Method Summary collapse

Instance Method Details

#error_for(object_name, attribute, **options) ⇒ Object



94
95
96
# File 'lib/optimism.rb', line 94

def error_for(object_name, attribute, **options)
  tag.span options.merge! id: error_id_for(object_name, attribute)
end

#error_id_for(object_name, attribute) ⇒ Object



98
99
100
# File 'lib/optimism.rb', line 98

def error_id_for(object_name, attribute)
  Optimism.error_selector.sub("RESOURCE", object_name.to_s.delete("]").tr("[", "_")).sub("ATTRIBUTE", attribute.to_s)[1..-1]
end