Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

determine if request is xhr? #1817

Closed
bonyiii opened this issue Jun 22, 2011 · 3 comments
Closed

determine if request is xhr? #1817

bonyiii opened this issue Jun 22, 2011 · 3 comments

Comments

@bonyiii
Copy link

bonyiii commented Jun 22, 2011

In rails 3.1.0.rc4

File actionpack/lib/action_dispatch/http/request.rb, line 148

reads

@env['HTTP_X_REQUESTED_WITH'] =~ /XMLHttpRequest/i

but it should be something like this:

(@env['HTTP_X_REQUESTED_WITH'] =~ /XMLHttpRequest/i).nil? ? false : true
@fxn
Copy link
Member

fxn commented Jun 22, 2011

The =~ operator returns a value whose boolean interpretation is true or false. That's all a predicate is required to do.

@fxn fxn closed this as completed Jun 22, 2011
@bonyiii
Copy link
Author

bonyiii commented Jun 22, 2011

No it returns the position the first match which could be 0 and it will be evaluated false then.

@fxn
Copy link
Member

fxn commented Jun 22, 2011

You need to double-check your Ruby ;).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants