.rjs not run unless I manually set the Content-type header

I’ve got this is my controller

def destroy
@headers[‘Content-Type’] = ‘text/javascript; charset=utf-8’

and this in my .rjs file called destroy.rjs

page.visual_effect :shrink, ‘tip_’+params[:id], :duration => 3

This works, unless I uncomment the Content-Type line in the
controller. Setting this header should NOT be necessary though I think.
The correct content type for rjs should automatically be set by Rails.

I’ve searched the web for an answer, but the only thing that I found was
that something else was forcing an incorrect mimetype to be set. FYI:
I’m using Webrick in development mode.

Any ideas??


On Monday, August 07, 2006, at 9:28 AM, Jeroen wrote:


Posted via http://www.ruby-forum.com/.

Rails mailing list
[email protected]

I have run into this problem when I was using render_to_string. This
was setting the response header incorrectly and required me to manually
set it back so that the RJS would work.


do you have any other templates, namely, destroy.rhtml? if so, this
is most liekly the cause as rails will attempt to render, by default,
any .rhtml or .rxml templates BEFORE .rjs templates.