diff options
author | Carl Lerche <carllerche@mac.com> | 2010-04-03 09:21:44 -0700 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-04-03 09:22:00 -0700 |
commit | 6e18fa0375b7116328fbee920c074006962a52e8 (patch) | |
tree | 4e9899aa3fdee2f504645c888e39115381c83d12 /activerecord | |
parent | 52ffaa182ea323af120dc5687d7547004167d0da (diff) | |
download | rails-6e18fa0375b7116328fbee920c074006962a52e8.tar.gz rails-6e18fa0375b7116328fbee920c074006962a52e8.tar.bz2 rails-6e18fa0375b7116328fbee920c074006962a52e8.zip |
Raise a StatementInvalid error when trying to build a condition with hash keys that do not correspond to columns.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation/predicate_builder.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb index 717756418c..d0efa2189d 100644 --- a/activerecord/lib/active_record/relation/predicate_builder.rb +++ b/activerecord/lib/active_record/relation/predicate_builder.rb @@ -20,7 +20,9 @@ module ActiveRecord 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 |