Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| error_class = "with_errors" if html_tag =~ /<label/ error_message = instance.object.errors.on(instance.method_name) html_tag.sub! /<\/label>/, " <em class=\"#{error_class}\">#{error_message}</em></label>" elsif html_tag =~ /<(input|textarea|select)[^>]+class=/ class_attribute = html_tag =~ /class=['"]/ html_tag.insert(class_attribute + 7, "#{error_class} ") elsif html_tag =~ /<(input|textarea|select)/ first_whitespace = html_tag =~ /\s/ html_tag[first_whitespace] = " class=\"#{error_class}\" " end html_tag end
This paste will be private.
From the Design Piracy series on my blog: