aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers
diff options
context:
space:
mode:
authorschneems <richard.schneeman@gmail.com>2012-08-09 23:59:25 -0500
committerschneems <richard.schneeman@gmail.com>2012-08-10 22:02:48 -0500
commit60b650b18c82a050ab81f924e23f7d308ffd8972 (patch)
treed95cebb615c2fbacc0ae445da8bf16e5d559f1bc /actionpack/lib/action_view/helpers
parent581a9277102e66132a98cd1e8df93f904628585e (diff)
downloadrails-60b650b18c82a050ab81f924e23f7d308ffd8972.tar.gz
rails-60b650b18c82a050ab81f924e23f7d308ffd8972.tar.bz2
rails-60b650b18c82a050ab81f924e23f7d308ffd8972.zip
check for nil or empty record in form_for
if nil or an empty array is passed into form_for you get a horrible error message, this one is much more indicative of what the programmer needs to know to fix the problem.
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index 5cfcfdd8d5..5dc5bb8a98 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -423,6 +423,7 @@ module ActionView
object = nil
else
object = record.is_a?(Array) ? record.last : record
+ raise ArgumentError, "First argument in form cannot contain nil or be empty" if object.blank?
object_name = options[:as] || model_name_from_record_or_class(object).param_key
apply_form_for_options!(record, object, options)
end