Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source
Show
Ignore:
Timestamp:
12/03/07 01:47:21 (1 year ago)
Author:
david
Message:

Fixed that to_xml should not automatically pass :procs to associations included with :include (closes #10162) [chuyeow]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/lib/active_record/serializers/xml_serializer.rb

    r8138 r8258  
    22  module Serialization 
    33    # Builds an XML document to represent the model.   Some configuration is 
    4     # available through +options+, however more complicated cases should  
     4    # available through +options+, however more complicated cases should 
    55    # override ActiveRecord's to_xml. 
    66    # 
    7     # By default the generated XML document will include the processing  
     7    # By default the generated XML document will include the processing 
    88    # instruction and all object's attributes.  For example: 
    9     #     
     9    # 
    1010    #   <?xml version="1.0" encoding="UTF-8"?> 
    1111    #   <topic> 
     
    4343    #     <last-read type="date">2004-04-15</last-read> 
    4444    #   </topic> 
    45     #  
     45    # 
    4646    # To include first level associations use :include 
    4747    # 
     
    190190    def add_tag(attribute) 
    191191      builder.tag!( 
    192         dasherize? ? attribute.name.dasherize : attribute.name,  
    193         attribute.value.to_s,  
     192        dasherize? ? attribute.name.dasherize : attribute.name, 
     193        attribute.value.to_s, 
    194194        attribute.decorations(!options[:skip_types]) 
    195195      ) 
     
    205205          builder.tag!(tag, :type => :array) do 
    206206            association_name = association.to_s.singularize 
    207             records.each do |record|  
     207            records.each do |record| 
    208208              record.to_xml opts.merge( 
    209                 :root => association_name,  
     209                :root => association_name, 
    210210                :type => (record.class.to_s.underscore == association_name ? nil : record.class.name) 
    211211              ) 
     
    232232      builder.tag!(*args) do 
    233233        add_attributes 
     234        procs = options.delete(:procs) 
    234235        add_includes { |association, records, opts| add_associations(association, records, opts) } 
     236        options[:procs] = procs 
    235237        add_procs 
    236238        yield builder if block_given?