aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-01-14 15:40:34 -0700
committerSean Griffin <sean@thoughtbot.com>2015-01-14 15:42:24 -0700
commit787e22bb491bd8c36db1e9734261c4ce02c5c5fd (patch)
treedfe8700206807038d9a8d89f520410f0bc9e2da9 /actionview/lib/action_view
parentdf73d696f5a965b67c9f177bf4dd8d85921d0214 (diff)
downloadrails-787e22bb491bd8c36db1e9734261c4ce02c5c5fd.tar.gz
rails-787e22bb491bd8c36db1e9734261c4ce02c5c5fd.tar.bz2
rails-787e22bb491bd8c36db1e9734261c4ce02c5c5fd.zip
Don't use the `_before_type_cast` version of attributes in the form
We should never be ignoring valuable information that the types may need to give us. The reason that it originally used `_before_type_cast` is unclear, but appears to date back long enough that the reasons may not be relevant today. There is only one test that asserts that it uses the before type cast version, but it gives no context as to why and uses a mock which does not simulate the real world. Fixes #18523.
Diffstat (limited to 'actionview/lib/action_view')
-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, 2 insertions, 12 deletions
diff --git a/actionview/lib/action_view/helpers/tags/base.rb b/actionview/lib/action_view/helpers/tags/base.rb
index f8abb19698..2b197c33c6 100644
--- a/actionview/lib/action_view/helpers/tags/base.rb
+++ b/actionview/lib/action_view/helpers/tags/base.rb
@@ -28,16 +28,6 @@ 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 69038c1498..4efe2d9ec8 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_before_type_cast(object) }, options)
+ content_tag("textarea", options.delete("value") { value(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 5c576a20ca..c18d541770 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_before_type_cast(object) } unless field_type == "file"
+ options["value"] = options.fetch("value") { value(object) } unless field_type == "file"
add_default_name_and_id(options)
tag("input", options)
end