Permalink
Browse files

Simplify unless conditional with OR

  • Loading branch information...
1 parent 872a17d commit 816efacb1f619a85cc5b3425c216bb0c0c766d18 @carlosantoniodasilva carlosantoniodasilva committed May 4, 2014
Showing with 2 additions and 4 deletions.
  1. +2 −4 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -393,10 +393,8 @@ def without_prepared_statement?(binds)
def column_for(table_name, column_name) # :nodoc:
column_name = column_name.to_s
- unless column = columns(table_name).detect { |c| c.name == column_name }
- raise ActiveRecordError, "No such column: #{table_name}.#{column_name}"
- end
- column
+ columns(table_name).detect { |c| c.name == column_name } ||
+ raise(ActiveRecordError, "No such column: #{table_name}.#{column_name}")
end
end
end

0 comments on commit 816efac

Please sign in to comment.