Bugs: Browse | Submit New | Admin

[#17970] Glassfish Gem deployement makes rails believe all requests are AJAX requests

Date:
2008-02-11 21:44
Priority:
3
Submitted By:
Nobody
Assigned To:
Pramod Gopinath (pramodg)
Category:
None
State:
Closed
Target Release:
 
Summary:
Glassfish Gem deployement makes rails believe all requests are AJAX requests

Detailed description
Wow, first bug report, I'm so living on the edge!

OK,

In my Rails app, in my controllers, I test request.xhr? to reply differently to AJAX requests (I use the same URL semantic
but don't reply with a layout usually).

The thing is that when deploying with the Glassfish gem it seems like request.xhr? is always true.

Simply try rais request.xhr?.inspect somewhere in your controller and you'll understand what I mean. Instead, in webrick
only real AJAX requests would raise 'true'.

Great work aside from this bug, thanks!

Raphaël Valyi.

Add A Comment: Notepad

Please login


Followup

Message
Date: 2008-11-06 05:12
Sender: Vivek Pandey

I think we have fixed this bug in upcoming 0.9.0 release. To
be released soon, let us know if it fixes your problem.
Date: 2008-03-14 11:56
Sender: Raphaël Valyi

Hi Pramod,

Looking good so far. I haven't tested it very extensively, especially
on the perf side, but I can tell you that my quite complex Rails
app with tons of Ajax (so that one is gone), cookies hacks, REST
and co is working fine on Glassfish with your gem. I'm very happy,
thank you for you efforts.

Look like the best deploying option I ever found for Rails,
GREAT!

Raphaël Valyi.
Date: 2008-03-14 05:05
Sender: Pramod Gopinath

Have released a new gem v0.1.2 that should solve your problem.
Had tested you application using the sample code that you had
provided. Could U confirm that your issue is resolved in the
latest gem.
Thanks again for Ur detailed test case.
Date: 2008-02-26 05:09
Sender: Pramod Gopinath

Thanks a lot for the detailed test case. Still learning Rails
hence having these detailed steps was very helpful.

I was able to reproduce this issue with the existing gem v0.1.1.
This is fixed as part of the solution for issue 4228  listed
here ; https://glassfish.dev.java.net/issues/show_bug.cgi?id=4228
.

Thanks to Thomas Enebo for helping to identify this issue.
Date: 2008-02-25 22:34
Sender: Raphaël Valyi

Here is a more explicit test case:

fist of all scallfold a basic Rails app
>rails glassfish_rails

then disable ActiveRecord as you don't need it, in
config/environment.rb,
uncomment that line:
  config.frameworks -= [:active_record, :active_resource,
:action_mailer ]
(around line 21)


then write such a controller called
app/controllers/test_controller.rb:

class TestController < ApplicationController
def test1; end
def test2; end
end


then write a /views/test/test2.rhtml view like that:

<%= javascript_include_tag 'prototype' %>

<%= link_to_remote("Try to click here to see inspect
request.xhr? for an ajax request:
", :update => "test", :url => url_for(:controller
=> 'test', :action => 'test1')) %>
<br/>
<div id = 'test'>
Result here...
</div>
<br/>
<br/>
<%= link_to("And now compare with a non Ajax request",
url_for(:controller => 'test', :action => 'test1'))%>



now write a /views/test/test1.rhtml view like that:
request.xhr? is <%= request.xhr? %>



Then launch the app with jruby script/server and point your browser
to:
http://localhost:3000/test/test2

try to click on both links to see the difference (ajax call should
reply true while non ajax should reply false).

Now try with the glassfish gem: the result is different: both
are true now!

Hope this helps!

Raphaël Valyi

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

Field Old Value Date By
close_date2008-12-04 20:552008-12-04 20:55vivekp
artifact_group_idv0.9.02008-12-04 20:55vivekp
resolution_idNone2008-11-06 05:12vivekp
close_date2008-11-06 05:122008-11-06 05:12vivekp
artifact_group_idNone2008-11-06 05:12vivekp
status_idOpen2008-11-06 05:12vivekp
assigned_tonone2008-02-13 18:52pramodg