Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

layout does not include application.xml.builder in rails 2.2/2.3

#2265

I have a lot of format.xml responses in my controllers. All of them renders with the default xml layout: application.xml.builder, which is simple xml.instruct!, followed by flash nodes, then the active records (to_xml). In rails 2.2/2.3, the layout has stopped rendering. I have googled and asked around without any luck. Would you please investigate? I wrote a simple rails app to illustrate the point:

I have one model - user.rb: class User < ActiveRecord::Base def name

"foo"

end end

and users_controller.rb: class UsersController < ApplicationController def index

respond_to do |format|
  format.html
  format.xml do
    render :xml => User.new, :layout => 'application'
  end
end

end end

I defined routes for it: map.resources :users

Then I change this to vary rails' versions for testing: RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION

Using :layout => 'application' or not doesn't matter. When I hit http://localhost:3000/users.xml I get this output:

Processing UsersController#index to xml (for 127.0.0.1 at 2009-03-16 17:41:10) [GET] [4;36;1mSQL (0.3ms) [0;1mSET SQL_AUTO_IS_NULL=0 [4;35;1mUser Columns (1.5ms) SHOW FIELDS FROM users Rendering template within layouts/application Completed in 34ms (View: 6, DB: 2) | 200 OK [http://localhost/ users.xml]

As you can see, it is renderin layouts/application.

I have defined views/layouts/application.xml.builder as such: xml.instruct!

xml.response do

xml << yield

end

And what I get is:

<created-at type="datetime" nil="true"/> <updated-at type="datetime" nil="true"/>

What I expect to get is xml instruct on top, then a response node, with user inside.

Reported by zlu · March 17th, 2009 @ 06:33 AM

State: stale
Milestone: 3.x
Assigned to: Frederick Cheung Frederick Cheung
Importance: none

Activity

  1. zlu
    zlu
    • Title changed from not including application.xml.builder in rails 2.2/2.3 to layout does not include application.xml.builder in rails 2.2/2.3

    March 18th, 2009 @ 05:55 AM

  2. zlu
    zlu
    • Assigned user set to Frederick Cheung

    May 12th, 2009 @ 10:57 PM

  3. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  4. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open
    • Importance changed from to

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:53 PM

  5. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:53 PM