diff options
author | Michael Koziarski <michael@koziarski.com> | 2007-06-30 03:31:48 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2007-06-30 03:31:48 +0000 |
commit | d0ff4ec1936b6888ce199ef5131c3a2d866a968c (patch) | |
tree | 2432d3e567b68d6ee2a0e328ff8b2cd9438aa075 /activerecord/lib | |
parent | 20045df2606a6c0c62bacfb9f9cb815ed11f7dd8 (diff) | |
download | rails-d0ff4ec1936b6888ce199ef5131c3a2d866a968c.tar.gz rails-d0ff4ec1936b6888ce199ef5131c3a2d866a968c.tar.bz2 rails-d0ff4ec1936b6888ce199ef5131c3a2d866a968c.zip |
Don't call unsupported methods on associated objects when using :include, :method with to_xml [manfred, jwilger] Closes #7307
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7156 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/xml_serialization.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/xml_serialization.rb b/activerecord/lib/active_record/xml_serialization.rb index df50ecc017..88ff46a004 100644 --- a/activerecord/lib/active_record/xml_serialization.rb +++ b/activerecord/lib/active_record/xml_serialization.rb @@ -178,10 +178,12 @@ module ActiveRecord #:nodoc: end def serializable_method_attributes - Array(options[:methods]).collect { |name| MethodAttribute.new(name.to_s, @record) } + Array(options[:methods]).inject([]) do |method_attributes, name| + method_attributes << MethodAttribute.new(name.to_s, @record) if @record.respond_to?(name.to_s) + method_attributes + end end - def add_attributes (serializable_attributes + serializable_method_attributes).each do |attribute| add_tag(attribute) |