Sha256: 50a3997037d343a84ebe5a5c9af9ab845283a4fdd3ae1574e0a3c59155f4bf93
Contents?: true
Size: 648 Bytes
Versions: 1
Compression:
Stored size: 648 Bytes
Contents
module RailsUjsForm module Helper # 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> def render_errors(builder) errors = builder.object.errors messages = errors.full_messages 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]}") { messages[i] } end output.html_safe end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails-ujs-form-0.2.0 | lib/rails-ujs-form/helper.rb |