aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2010-08-27 01:16:27 -0300
committerSantiago Pastorino <santiago@wyeworks.com>2010-08-27 09:08:04 -0300
commitf95ba5c262bfd713f0a2fc656f8e645d3eea60f2 (patch)
treefc91e39178da1031d307fa14f54e66b772d52721 /actionpack/lib
parentf98694b624749488d9cc6ff6829d437df4bca1bf (diff)
downloadrails-f95ba5c262bfd713f0a2fc656f8e645d3eea60f2.tar.gz
rails-f95ba5c262bfd713f0a2fc656f8e645d3eea60f2.tar.bz2
rails-f95ba5c262bfd713f0a2fc656f8e645d3eea60f2.zip
Make InstanceTagMethods#value_before_type_cast raise if the model don't respond to attr_before_type_cast or attr method
[#3374] [#5471 state:committed]
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index ebe055bebd..938da7aea7 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -1006,9 +1006,14 @@ module ActionView
def value_before_type_cast(object, method_name)
unless object.nil?
- object.respond_to?(method_name) ?
- object.send(method_name) :
- object.send(method_name + "_before_type_cast")
+ if object.respond_to?(method_name)
+ object.send(method_name)
+ # FIXME: this is AR dependent
+ elsif object.respond_to?(method_name + "_before_type_cast")
+ object.send(method_name + "_before_type_cast")
+ else
+ raise NoMethodError, "Model #{object.class} does not respond to #{method_name}"
+ end
end
end