Jeroen
2006-Aug-07 07:28 UTC
[Rails] .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 -- Posted via http://www.ruby-forum.com/.
Kevin Olbrich
2006-Aug-07 11:44 UTC
[Rails] .rjs not run unless I manually set the Content-type header
On Monday, August 07, 2006, at 9:28 AM, Jeroen wrote:>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 > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsI 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 -- Posted with http://DevLists.com. Sign up and save your mailbox.
Chris Hall
2006-Aug-07 12:34 UTC
[Rails] .rjs not run unless I manually set the Content-type header
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 On 8/7/06, Jeroen <jeroen@supercool.nl> wrote:> 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 > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >