Permalink
Browse files

Revert "Make InstanceTagMethods#value_before_type_cast raise if the m…

…odel don't respond to attr_before_type_cast or attr method"

And    "Makes form_helper use overriden model accessors"

This reverts commit 3ba8e31 and fb0bd8c.
  • Loading branch information...
1 parent cc8e386 commit cb26eee54d34eda966b4c9da810b700cce24f824 @spastorino spastorino committed Oct 10, 2010
Showing with 3 additions and 38 deletions.
  1. +3 −8 actionpack/lib/action_view/helpers/form_helper.rb
  2. +0 −30 actionpack/test/template/form_helper_test.rb
@@ -1020,14 +1020,9 @@ def value(object, method_name)
def value_before_type_cast(object, method_name)
unless object.nil?
- 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
+ object.respond_to?(method_name + "_before_type_cast") ?
+ object.send(method_name + "_before_type_cast") :
+ object.send(method_name)
end
end
@@ -4,18 +4,6 @@
class FormHelperTest < ActionView::TestCase
tests ActionView::Helpers::FormHelper
- class Developer
- def name_before_type_cast
- "David"
- end
-
- def name
- "Santiago"
- end
-
- attr_writer :language
- end
-
def form_for(*)
@output_buffer = super
end
@@ -278,24 +266,6 @@ def test_text_field_with_custom_type
text_field("user", "email", :type => "email")
end
- def test_text_field_from_a_user_defined_method
- @developer = Developer.new
- assert_dom_equal(
- '<input id="developer_name" name="developer[name]" size="30" type="text" value="Santiago" />', text_field("developer", "name")
- )
- end
-
- def test_text_field_on_a_model_with_undefined_attr_reader
- @developer = Developer.new
- @developer.language = 'ruby'
- begin
- text_field("developer", "language")
- rescue NoMethodError => error
- message = error.message
- end
- assert_equal "Model #{Developer} does not respond to language", message
- end
-
def test_check_box
assert_dom_equal(
'<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',

5 comments on commit cb26eee

Sorry if this is the wrong place to comment/ask question.

But will this change be backported to 2.3.x ?

Thanks,
Andy

Owner

spastorino replied Oct 13, 2010

shenie this change is already in 2.3.x

Ah thanks. Forgot to check it out on 2-3-stable. Guess it'll be out when the next release happens eh. Any idea on when it'll happen?

Owner

spastorino replied Oct 14, 2010

Today 3.0.1 and 2.3.10 ;)

Sweet~~ thx

Please sign in to comment.