diff options
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 11 |
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 |