Exists is only really for indicating whether or not there's a record
associated with that ID, if you want to obey all those other rules you
can just use .first(...) right? I'm -1 on this as it stands as exists
I'm not sure what you mean by "all those other rules". The exists?
method does take scope into account, but only partially - it
ignores :include - and so it bombs in certain scenarios (see my test
case). This bug needs to be fixed. If my fix is not appropriate, then
I would really appreciate if you could explain why, and even better if
you could propose an alternative approach.
is really only there for this high-performance use case e.g. rarely
Well, I'm not sure it is relevant to discuss how often the method is
used here. The method is a public part of the API and has been for a
long time AFAIK and it needs to work. Correct functionality trumps
performance. Note that exists? is invoked by include? in
association_collection.rb. That's how the bug was triggered for me.
Do you think there is a significant performance impact of my change
and if so why?
Thanks for taking the time to discuss this!