request.xhr? always returns Object or nil , not true or false , since it is based on matching with a regular expression pattern (see here ).
In Ruby, any value other than false and nil is the true value (like the 0 returned by request.xhr? ), So the answer is correct.
source share