diff options
author | Marcel Molina <marcel@vernix.org> | 2006-01-13 01:51:45 +0000 |
---|---|---|
committer | Marcel Molina <marcel@vernix.org> | 2006-01-13 01:51:45 +0000 |
commit | f1a01c80dba9dd6545063d8f66ec299ea8f33b8c (patch) | |
tree | 0605a2cb0c2bb5e84e089fd1089a2173aa810b45 /activerecord/lib | |
parent | 2b7f1cdbe9204d68ed5db41229cd48bba8e0225b (diff) | |
download | rails-f1a01c80dba9dd6545063d8f66ec299ea8f33b8c.tar.gz rails-f1a01c80dba9dd6545063d8f66ec299ea8f33b8c.tar.bz2 rails-f1a01c80dba9dd6545063d8f66ec299ea8f33b8c.zip |
Disambiguate table names for columns in validates_uniquness_of's WHERE clause. Closes #3423.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3402 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/validations.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index a7e7bd1f26..27ca8d37d1 100755 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -496,17 +496,17 @@ module ActiveRecord configuration.update(attr_names.pop) if attr_names.last.is_a?(Hash) validates_each(attr_names,configuration) do |record, attr_name, value| - condition_sql = "#{attr_name} #{attribute_condition(value)}" + condition_sql = "#{record.class.table_name}.#{attr_name} #{attribute_condition(value)}" condition_params = [value] if scope = configuration[:scope] Array(scope).map do |scope_item| scope_value = record.send(scope_item) - condition_sql << " AND #{scope_item} #{attribute_condition(scope_value)}" + condition_sql << " AND #{record.class.table_name}.#{scope_item} #{attribute_condition(scope_value)}" condition_params << scope_value end end unless record.new_record? - condition_sql << " AND #{record.class.primary_key} <> ?" + condition_sql << " AND #{record.class.table_name}.#{record.class.primary_key} <> ?" condition_params << record.send(:id) end if record.class.find(:first, :conditions => [condition_sql, *condition_params]) |