This project is archived and is in readonly mode.
layout does not include application.xml.builder in rails 2.2/2.3
Reported by zlu | March 17th, 2009 @ 06:33 AM | in 3.x
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.
Comments and changes to this ticket
-
zlu March 18th, 2009 @ 05:55 AM
- 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
-
zlu May 12th, 2009 @ 10:57 PM
- Assigned user set to Frederick Cheung
-
Santiago Pastorino February 2nd, 2011 @ 04:53 PM
- 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.
-
Santiago Pastorino February 2nd, 2011 @ 04:53 PM
- State changed from open to stale
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>