Permalink
Browse files

Raise a StatementInvalid error when trying to build a condition with …

…hash keys that do not correspond to columns.
  • Loading branch information...
1 parent 52ffaa1 commit 6e18fa0375b7116328fbee920c074006962a52e8 Carl Lerche committed Apr 3, 2010
Showing with 3 additions and 1 deletion.
  1. +3 −1 activerecord/lib/active_record/relation/predicate_builder.rb
@@ -20,7 +20,9 @@ def build_from_hash(attributes, default_table)
table = Arel::Table.new(table_name, :engine => @engine)
end
- attribute = table[column]
+ unless attribute = table[column]
+ raise StatementInvalid, "No attribute named `#{column}` exists for table `#{table.name}`"
+ end
case value
when Array, ActiveRecord::Associations::AssociationCollection, ActiveRecord::Relation

0 comments on commit 6e18fa0

Please sign in to comment.