diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-05 11:48:40 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-05 15:36:36 -0700 |
commit | 06d518a32398a4dc7564f45aa19575ea7fa702da (patch) | |
tree | 305d87821026686697a319b9fd53fd4c4e527b67 /activerecord | |
parent | 29b54a41d9cd9b5b8902429be4adedf4a296fa9d (diff) | |
download | rails-06d518a32398a4dc7564f45aa19575ea7fa702da.tar.gz rails-06d518a32398a4dc7564f45aa19575ea7fa702da.tar.bz2 rails-06d518a32398a4dc7564f45aa19575ea7fa702da.zip |
stop recursively calling exists?
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index ab9f10b380..e9e9c85122 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -171,14 +171,16 @@ module ActiveRecord def exists?(id = nil) id = id.id if ActiveRecord::Base === id + relation = select(primary_key).limit(1) + case id when Array, Hash - where(id).exists? + relation = relation.where(id) else - relation = select(primary_key).limit(1) relation = relation.where(primary_key.eq(id)) if id - relation.first ? true : false end + + relation.first ? true : false end protected |