0
-module ActionView::Helpers::ActiveRecordHelper
0
- # Returns a string with a div containing all of the error messages for the object and method located as instance variables by the names
0
- # given. This method mimics the output of +error_messages_for+, and is meant to be used in leau of +error_message_on+.
0
- # This div can be tailored by the following options:
0
- # * <tt>id</tt> - The id of the error div (default: errorExplanation)
0
- # * <tt>class</tt> - The class of the error div (default: errorExplanation)
0
- # * <tt>method_name</tt> - The object name to use in the header, or
0
- # any text that you prefer. If <tt>method_name</tt> is not set, the name of
0
- # the method will be used.
0
- # Specifying one object:
0
- # error_messages_on 'user', 'login'
0
- # NOTE: This is a pre-packaged presentation of the errors with embedded strings and a certain HTML structure. If what
0
- # you need is significantly different from the default presentation, it makes plenty of sense to access the object.errors
0
- # instance yourself and set it up. View the source of this method to see how easy it is.
0
- def error_messages_on(object, method, options = {})
0
- options.stringify_keys!
0
- ['id', 'class'].each do |key|
0
- if options.include?(key)
0
- html[key] = value unless value.blank?
0
- html[key] = 'errorExplanation'
0
- name = options['method_name'] ||= method.to_s.humanize.capitalize
0
- if (obj = instance_variable_get("@#{object}")) && (errors = obj.errors.on(method))
0
- content_tag(:ul, errors.map {|msg| content_tag(:li, "#{name} #{msg}") }),
0
- def errors_to_s(errors)
0
- "#{e.humanize unless e == "base"} #{m}\n"
0
\ No newline at end of file