diff options
author | kennyj <kennyj@gmail.com> | 2013-07-24 23:05:26 +0900 |
---|---|---|
committer | kennyj <kennyj@gmail.com> | 2013-07-24 23:24:22 +0900 |
commit | 19291bff34ce8e36117f07e6e1d546d8ee47529f (patch) | |
tree | 72106cc6ddd76def86a70963fe1320d281c97523 /activerecord/lib/active_record | |
parent | 3a4d0b1e2975122defe86de31fc35ab2dcd9b984 (diff) | |
download | rails-19291bff34ce8e36117f07e6e1d546d8ee47529f.tar.gz rails-19291bff34ce8e36117f07e6e1d546d8ee47529f.tar.bz2 rails-19291bff34ce8e36117f07e6e1d546d8ee47529f.zip |
Simplify select_one method.
The select_all method always returns ActiveRecord::Result instance,
and the ActiveRecord::Result includes Enumerable mixin.
If #empty?, #first method returns nil. Thus we can simplify this method.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb index 3e79b71fb3..11f5bd5d3c 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -26,8 +26,7 @@ module ActiveRecord # Returns a record hash with the column names as keys and column values # as values. def select_one(arel, name = nil, binds = []) - result = select_all(arel, name, binds) - result.first if result + select_all(arel, name, binds).first end # Returns a single value from a record |