Module: ActionView::Helpers::ActiveRecordHelper
- Defined in:
- lib/plugins/monkey_patches/lib/monkey_patches.rb
Overview
So we get error messages wrapped in a span instead of a div which will tend to mess up forms
Instance Method Summary collapse
Instance Method Details
#error_message_on(object, method, *args) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/plugins/monkey_patches/lib/monkey_patches.rb', line 9 def (object, method, *args) = args. unless args.empty? ActiveSupport::Deprecation.warn('error_message_on takes an option hash instead of separate ' + 'prepend_text, append_text, and css_class arguments', caller) [:prepend_text] = args[0] || '' [:append_text] = args[1] || '' [:css_class] = args[2] || 'formError' end .reverse_merge!(:prepend_text => '', :append_text => '', :css_class => 'formError') if (obj = (object.respond_to?(:errors) ? object : instance_variable_get("@#{object}"))) && (errors = obj.errors.on(method)) content_tag("span", "#{[:prepend_text]}#{errors.is_a?(Array) ? errors.first : errors}#{[:append_text]}", :class => [:css_class] ) else '' end end |