Browse files

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.
  • Loading branch information...
1 parent 3a4d0b1 commit 19291bff34ce8e36117f07e6e1d546d8ee47529f @kennyj kennyj committed Jul 24, 2013
@@ -26,8 +26,7 @@ def select_all(arel, name = nil, binds = [])
# 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
# Returns a single value from a record

0 comments on commit 19291bf

Please sign in to comment.