aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/active_record_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_view/helpers/active_record_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/active_record_helper.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/active_record_helper.rb b/actionpack/lib/action_view/helpers/active_record_helper.rb
index 41d63fbc9a..dccae1db41 100644
--- a/actionpack/lib/action_view/helpers/active_record_helper.rb
+++ b/actionpack/lib/action_view/helpers/active_record_helper.rb
@@ -103,7 +103,7 @@ module ActionView
def error_messages_for(object_name, options = {})
options = options.symbolize_keys
object = instance_variable_get("@#{object_name}")
- unless object.errors.empty?
+ if object && !object.errors.empty?
content_tag("div",
content_tag(
options[:header_tag] || "h2",
@@ -113,6 +113,8 @@ module ActionView
content_tag("ul", object.errors.full_messages.collect { |msg| content_tag("li", msg) }),
"id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation"
)
+ else
+ ""
end
end