diff options
author | Michael Koziarski <michael@koziarski.com> | 2006-01-19 08:47:18 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2006-01-19 08:47:18 +0000 |
commit | e3898491f2960890d866bfe08e221a4cb52cfccc (patch) | |
tree | 3262187d7f3e87561648e23f9847b56824f6a304 /actionpack/lib/action_view | |
parent | 363b79f9428395249d7509ddc88e1080902d6256 (diff) | |
download | rails-e3898491f2960890d866bfe08e221a4cb52cfccc.tar.gz rails-e3898491f2960890d866bfe08e221a4cb52cfccc.tar.bz2 rails-e3898491f2960890d866bfe08e221a4cb52cfccc.zip |
make error_messages_for return "" for nil objects
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3438 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/active_record_helper.rb | 4 |
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 |