aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-01-14 16:44:06 -0700
committerSean Griffin <sean@thoughtbot.com>2015-01-14 16:44:06 -0700
commit99b6cf538145fb34c08f81a6fc495e7fbb0510ae (patch)
treea55920155a6f7301cf4250f8589faf7c46b27cce /actionview/lib
parent787e22bb491bd8c36db1e9734261c4ce02c5c5fd (diff)
downloadrails-99b6cf538145fb34c08f81a6fc495e7fbb0510ae.tar.gz
rails-99b6cf538145fb34c08f81a6fc495e7fbb0510ae.tar.bz2
rails-99b6cf538145fb34c08f81a6fc495e7fbb0510ae.zip
Revert "Don't use the `_before_type_cast` version of attributes in the form"
This reverts commit 787e22bb491bd8c36db1e9734261c4ce02c5c5fd.
Diffstat (limited to 'actionview/lib')
-rw-r--r--actionview/lib/action_view/helpers/tags/base.rb10
-rw-r--r--actionview/lib/action_view/helpers/tags/text_area.rb2
-rw-r--r--actionview/lib/action_view/helpers/tags/text_field.rb2
3 files changed, 12 insertions, 2 deletions
diff --git a/actionview/lib/action_view/helpers/tags/base.rb b/actionview/lib/action_view/helpers/tags/base.rb
index 2b197c33c6..f8abb19698 100644
--- a/actionview/lib/action_view/helpers/tags/base.rb
+++ b/actionview/lib/action_view/helpers/tags/base.rb
@@ -28,6 +28,16 @@ module ActionView
object.public_send @method_name if object
end
+ def value_before_type_cast(object)
+ unless object.nil?
+ method_before_type_cast = @method_name + "_before_type_cast"
+
+ object.respond_to?(method_before_type_cast) ?
+ object.send(method_before_type_cast) :
+ value(object)
+ end
+ end
+
def retrieve_object(object)
if object
object
diff --git a/actionview/lib/action_view/helpers/tags/text_area.rb b/actionview/lib/action_view/helpers/tags/text_area.rb
index 4efe2d9ec8..69038c1498 100644
--- a/actionview/lib/action_view/helpers/tags/text_area.rb
+++ b/actionview/lib/action_view/helpers/tags/text_area.rb
@@ -14,7 +14,7 @@ module ActionView
options["cols"], options["rows"] = size.split("x") if size.respond_to?(:split)
end
- content_tag("textarea", options.delete("value") { value(object) }, options)
+ content_tag("textarea", options.delete("value") { value_before_type_cast(object) }, options)
end
end
end
diff --git a/actionview/lib/action_view/helpers/tags/text_field.rb b/actionview/lib/action_view/helpers/tags/text_field.rb
index c18d541770..5c576a20ca 100644
--- a/actionview/lib/action_view/helpers/tags/text_field.rb
+++ b/actionview/lib/action_view/helpers/tags/text_field.rb
@@ -10,7 +10,7 @@ module ActionView
options = @options.stringify_keys
options["size"] = options["maxlength"] unless options.key?("size")
options["type"] ||= field_type
- options["value"] = options.fetch("value") { value(object) } unless field_type == "file"
+ options["value"] = options.fetch("value") { value_before_type_cast(object) } unless field_type == "file"
add_default_name_and_id(options)
tag("input", options)
end