This project is archived and is in readonly mode.

#1503 ✓wontfix
Kip Cole

Wrong mime type in rjs response in Rails 2.2.2 (sometimes)

Reported by Kip Cole | December 2nd, 2008 @ 01:40 AM | in 2.x

rjs templates in Rails 2.2.2 sometimes set the mime type of the response to text/html instead of text/javascript. Therefore no js interpreted in the browser. Rails 2.2.0 works correctly; 2.2.2 does not appear to.

Failure Example: http://www.noexpectations.com.au Scroll to the bottom of the page to cause a js request to the server which returns javascript from an rjs template. Header mime type is incorrectly set as text/html.

It does not happen in all cases. For example, http://www.noexpectations.com.au... has the same "endless page" functionality and in this case the rjs response has the correct mime type of text/javascript

Failing rjs template in 2.2.2 (works in 2.2.0): page.insert_html :bottom, :articles, :partial => "articles" if @articles.page_count > @articles.page page[:loading].hide page.call 'checkScroll' else page[:loading].hide end

Note partial :articles calls other .html.erb templates possibly causing response mime type to be overwritten (?):

<% for article in @articles -%>

<div id="<%= 'article_' + article.id.to_s -%>" class="_article" >
  <h2><%= link_to h(article.title), article %></h2>
  <%= render :partial => "article_byline", :locals => {:article => article} -%>
  <%= render_excerpt(article) -%>
  <%= render(:partial => "article_footer", :locals => {:article => article}) -%>
</div>

<% end %>

Comments and changes to this ticket

  • Kip Cole

    Kip Cole December 2nd, 2008 @ 02:19 AM

    I've rolled my site back to 2.2.0 for now so the examples above won't exhibit the behaviour I've described.

  • Kip Cole

    Kip Cole December 2nd, 2008 @ 03:33 AM

    Issue is that render_to_string now sets the response.content_type to nil (it didn't use to back in 2.2.0; I will track down the relevant commit).

    This means that using render_to_string and render in the same request cycle will break stuff in an unanticipated way.

    This ticket should be closed (I will open a proper one for the render_to_string issue).

  • josh

    josh December 3rd, 2008 @ 02:32 AM

    • State changed from “new” to “wontfix”

    Closing by request.

    Take a look at #870 or #1182, they sound related.

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>

People watching this ticket

Pages