Module: ActionView::Helpers::ErrorMessageForMobile
- Defined in:
- lib/action_view/helpers/error_message_for_mobile.rb
Defined Under Namespace
Modules: FormBuilderMethods
Instance Method Summary collapse
Instance Method Details
#error_message_for_mobile(object, method, *args) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/action_view/helpers/error_message_for_mobile.rb', line 10 def (object, method, *args) = args. unless args.empty? ActiveSupport::Deprecation.warn('error_message_for_mobile takes an option hash instead of separate ' + 'prepend_text, append_text, and color arguments', caller) [:prepend_text] = args[0] || '' [:append_text] = args[1] || '' [:color] = args[2] || '#ff0000' end .reverse_merge!(:prepend_text => '', :append_text => '', :color => '#ff0000') object = convert_to_model(object) if (obj = (object.respond_to?(:errors) ? object : instance_variable_get("@#{object}"))) && (errors = obj.errors[method]).presence html = content_tag("span", ([:prepend_text].html_safe << errors.first).safe_concat([:append_text]), :style => "color:#{[:color]};" ) html << '<br />' else '' end end |