Make xml_http_request? / xhr? actually return a boolean

Currently “xml_http_request” returns a booleanish value that behaves accordingly when needed but it also breaks the general convention that methods with a “?” postfix should return “true” or “false” values.


request.xml_http_request? # => 0 / nil


request.xml_http_request? # => true / false

PR at Make ActionDispatch::Resquest#xml_http_request? actually return a boolean. by lukelex · Pull Request #23865 · rails/rails · GitHub

Doesn't `request.xhr?` cover that?

Pretty sure this is not a general convention that Rails follows. This seemed awful familiar, a quick google search brought me to: attribute_changed? returns nil (instead of false) for unchanged attributes (4.2.1) · Issue #20110 · rails/rails · GitHub (which suggests that this type of issue is raised often).