This project is archived and is in readonly mode.
Action Controller always renders JS/JSON for XHRs
Reported by Peter Abrahamsen | December 18th, 2008 @ 12:01 AM | in 3.x
- Make two templates for an action, one .html.erb and the other .js.erb
- Make a get request that will be routed to that action with X-Requested-With: XMLHttpRequest.
- You will always get the .js.erb template, even though request.format will show e.g. text/html. This behaviour is reversed by requesting action/0.html, but not by setting the Accepts: header and use_accepts_header appropriately.
This was observed on an otherwise pristine 2.2 project. On our existing project, it was rendering HTML and then wrapping it in a JSON object, but I haven't looked into that enough.
Comments and changes to this ticket
-
Peter Abrahamsen December 18th, 2008 @ 12:34 AM
I've commented out action_controller/request.rb:182,183 (template_format, the elsif xhr? clause) and my life went back to normal.
-
Pratik March 13th, 2009 @ 03:44 PM
- State changed from new to incomplete
- Assigned user set to josh
- Title changed from ActionController always renders JS/JSON for XHRs to Action Controller always renders JS/JSON for XHRs
Could you please confirm if this is still a problem ? A failing test case would be awesome - http://guides.rails.info/contrib...
-
josh August 19th, 2009 @ 03:46 PM
- Assigned user cleared.
-
Santiago Pastorino February 2nd, 2011 @ 04:42 PM
- State changed from incomplete 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:42 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>