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

request.xhr? should return boolean value instead of Int #7510

Closed
wants to merge 1 commit into from
Closed

request.xhr? should return boolean value instead of Int #7510

wants to merge 1 commit into from

Conversation

zudochkin
Copy link
Contributor

I've just converted to boolean value

request.xhr?
  => 0`

I've just converted to boolean value
@fxn
Copy link
Member

fxn commented Sep 3, 2012

A predicate in Ruby does not need to return a singleton. That predicate returns a true or false value depending on whether the request is Ajax. And you use it like this

if request.xhr?
  ...
end

Ruby on Rails does not document singletons in general, so even if some predicates return a singleton today, they could not tomorrow. If you totally need a singleton you need in general to !! the value they return.

There was a long thread in the past about this in #5329.

@fxn fxn closed this Sep 3, 2012
@zudochkin
Copy link
Contributor Author

Thanks for your response and sorry, I didn't see #5329

@fxn
Copy link
Member

fxn commented Sep 3, 2012

No prob :).

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

Successfully merging this pull request may close these issues.

None yet

2 participants