Module: RailsUjsForm::Helper
- Defined in:
- lib/rails-ujs-form/helper.rb
Instance Method Summary collapse
-
#render_errors(builder) ⇒ Object
not sure why there isn’t something like this in rails.
Instance Method Details
#render_errors(builder) ⇒ Object
not sure why there isn’t something like this in rails
render the errors on an object in a fairly standard way:
<ul class=“errors”>
<li data-for="name">Name cannot be blank</li>
</ul>
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rails-ujs-form/helper.rb', line 10 def render_errors(builder) errors = builder.object.errors = errors. content_tag :ul, :class => :errors do output = '' errors.each_with_index do |error, i| output << content_tag(:li, :'data-for' => "#{builder.object_name}_#{error[0]}") { [i] } end output.html_safe end end |