Skip to content

Instantly share code, notes, and snippets.

@andreas
Created September 2, 2010 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreas/562146 to your computer and use it in GitHub Desktop.
Save andreas/562146 to your computer and use it in GitHub Desktop.
From e6ec1f637ab3d6c235eef05142abf373e08f5c4b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20Garn=C3=A6s?= <andreas.garnaes@gmail.com>
Date: Thu, 2 Sep 2010 12:35:37 +0200
Subject: [PATCH] ActiveModel#to_xml fix (renamed parameter).
---
activemodel/lib/active_model/serializers/xml.rb | 2 +-
activeresource/test/cases/base_test.rb | 6 ++++++
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/activemodel/lib/active_model/serializers/xml.rb b/activemodel/lib/active_model/serializers/xml.rb
index 16ab8e7..e89385e 100644
--- a/activemodel/lib/active_model/serializers/xml.rb
+++ b/activemodel/lib/active_model/serializers/xml.rb
@@ -17,7 +17,7 @@ module ActiveModel
def initialize(name, serializable, raw_value=nil)
@name, @serializable = name, serializable
- @value = value || @serializable.send(name)
+ @value = raw_value || @serializable.send(name)
@type = compute_type
end
diff --git a/activeresource/test/cases/base_test.rb b/activeresource/test/cases/base_test.rb
index 91b3756..77135be 100644
--- a/activeresource/test/cases/base_test.rb
+++ b/activeresource/test/cases/base_test.rb
@@ -1041,6 +1041,12 @@ class BaseTest < Test::Unit::TestCase
ensure
Person.element_name = old_elem_name
end
+
+ def test_to_xml_with_private_method_name_as_attribute
+ assert_nothing_raised(ArgumentError) {
+ Customer.new(:test => true).to_xml
+ }
+ end
def test_to_json
Person.include_root_in_json = true
--
1.7.0.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment