Class: ActionView::Helpers::FormBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/optimism.rb

Instance Method Summary collapse

Instance Method Details

#container_for(attribute, **options, &block) ⇒ Object



88
89
90
# File 'lib/optimism.rb', line 88

def container_for(attribute, **options, &block)
  @template.tag.div @template.capture(&block), options.merge!(id: container_id_for(attribute)) if block_given?
end

#container_id_for(attribute) ⇒ Object



92
93
94
# File 'lib/optimism.rb', line 92

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

#error_for(attribute, **options) ⇒ Object



96
97
98
# File 'lib/optimism.rb', line 96

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

#error_id_for(attribute) ⇒ Object



100
101
102
# File 'lib/optimism.rb', line 100

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