Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6507

Show
Ignore:
Timestamp:
04/08/07 17:16:36 (2 years ago)
Author:
rick
Message:

Change default respond_to templates for xml and rjs formats. [Rick]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r6506 r6507  
    11*SVN* 
     2 
     3* Change default respond_to templates for xml and rjs formats. [Rick] 
     4 
     5  * Default xml template goes from #{action_name}.rxml => #{action_name}.xml.builder. 
     6  * Default rjs template goes from #{action_name}.rjs => #{action_name}.js.rjs. 
    27 
    38* Fix WSOD due to modification of a formatted template extension so that requests to templates like 'foo.html.erb' fail on the second hit.  [Rick] 
  • trunk/actionpack/lib/action_controller/mime_responds.rb

    r5232 r6507  
    108108     
    109109    class Responder #:nodoc: 
    110       DEFAULT_BLOCKS = [:html, :js, :xml].inject({}) do |blocks, ext| 
    111         template_extension = (ext == :html ? '' : ".r#{ext}") 
    112         blocks.update ext => %(Proc.new { render :action => "\#{action_name}#{template_extension}", :content_type => Mime::#{ext.to_s.upcase} }) 
    113       end 
     110      default_block_format = %(Proc.new { render :action => "\#{action_name}%s", :content_type => Mime::%s }) 
     111      DEFAULT_BLOCKS = {} 
     112      DEFAULT_BLOCKS[:html] = default_block_format % ['', 'HTML'] 
     113      DEFAULT_BLOCKS[:js]   = default_block_format % ['.js.rjs', 'JS'] 
     114      DEFAULT_BLOCKS[:xml]  = default_block_format % ['.xml.builder', 'XML'] 
    114115       
    115116      def initialize(block_binding) 
  • trunk/actionpack/test/controller/mime_responds_test.rb

    r6120 r6507  
    352352 
    353353    get :using_defaults, :format => "xml" 
    354     assert_equal "using_defaults.rxml", @response.body 
     354    assert_equal "using_defaults.xml.builder", @response.body 
    355355  end 
    356356end