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.

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

#1503

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 %>

Reported by Kip Cole · December 2nd, 2008 @ 01:40 AM

State: wontfix
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Kip Cole
    Kip Cole

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

    December 2nd, 2008 @ 02:19 AM

  2. Kip Cole
    Kip Cole

    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).

    December 2nd, 2008 @ 03:33 AM

  3. josh
    josh
    • State changed from new to wontfix

    Closing by request.

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

    December 3rd, 2008 @ 02:32 AM