Sent this to the wrong list before, so here are the two emails I had
initially sent...

Email I sent yesterday...
================

The following is how "exists?" works between Rails 2.x and 3.x

Rails 2.x

>> User.exists?
=> true
>> User.exists?(nil)
=> false
>> Store.first.users.exists?
=> true
>> Store.first.users.exists?(nil)
=> false

Rails 3.x

>> User.exists?
=> true
>> User.exists?(nil)
=> true
>> Store.first.users.exists?
=> true
>> Store.first.users.exists?(nil)
=> true

Rails 3.x always returns true, but I don't believe this should be the
case and it should work as it was in rails 2.x.  Is there a reason for
the difference in Rails 3.x?  Passing nil should not return true
IMO... it doesn't make sense to do so.

I can submit a patch if the behaviour in Rails 3.x is deemed incorrect.

Regards,
Andrew

And my followup today....
================

Patch provided at https://github.com/rails/rails/pull/2485

Fixes cases where a params id may be nil; exists? should not return
true in this case.

params[:id] => nil
Topic.exists?(params[:id]) => false # should be false always, never true

Please +1

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to