代碼: |
def error_messages_for(object_name, options = {}) ? ?? ?options = options.symbolize_keys ? ?? ?object = instance_variable_get("@#{object_name}") ? ?? ?unless object.errors.empty? ? ?? ?? ?error_lis = [] ? ?? ?? ?object.errors.each{ |key,msg| error_lis << content_tag("li", msg) }? ? ? ?? ?? ?content_tag("div", ? ?? ?? ?content_tag(options[:header_tag] || "h2","發生了#{object.errors.count}個錯誤") + ? ?? ?? ?content_tag("p", "錯誤來源于以下原因,請參考:") + ? ?? ?? ?content_tag("ul", error_lis), ? ?? ?? ?"id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation" ? ?? ?? ?) ? ?? ?end ? ?end? ? ? ? |