diff options
author | Andrew Kaspick <andrew@redlinesoftware.com> | 2011-08-10 12:55:29 -0500 |
---|---|---|
committer | Andrew Kaspick <andrew@redlinesoftware.com> | 2011-08-10 12:55:29 -0500 |
commit | d48dd18bb2a3d0c46708a9ee217909783b997cb2 (patch) | |
tree | 6485c4d04da48ec5339dff401c471b9784f9ea2a /activerecord/lib/active_record | |
parent | bb4f687bc670932f93a7befe07bfb2859a61411a (diff) | |
download | rails-d48dd18bb2a3d0c46708a9ee217909783b997cb2.tar.gz rails-d48dd18bb2a3d0c46708a9ee217909783b997cb2.tar.bz2 rails-d48dd18bb2a3d0c46708a9ee217909783b997cb2.zip |
fix exists? to return false if passed nil (which may come from a missing URL param)
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 73368aed18..d0d138d2a6 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -180,7 +180,9 @@ module ActiveRecord # Person.exists?(:name => "David") # Person.exists?(['name LIKE ?', "%#{query}%"]) # Person.exists? - def exists?(id = nil) + def exists?(id = false) + return false if id.nil? + id = id.id if ActiveRecord::Base === id join_dependency = construct_join_dependency_for_association_find |