.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’
end

and this in my .rjs file called destroy.rjs

page.alert(‘test’)
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??

Jeroen

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

Jeroen


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


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

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.

_Kevin
www.sciwerks.com

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.

Chris

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs