diff options
author | Emilio Tagua <miloops@gmail.com> | 2010-11-21 00:46:28 +0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-24 01:37:02 +0800 |
commit | e2bad8a2e7e020901ddb74c3404a1c339b5a99f9 (patch) | |
tree | 879d97c69ea65c3b4dda3f77b908529c8cce3cb1 /activerecord | |
parent | d29d793c9096a732274298cdba07c654e9128484 (diff) | |
download | rails-e2bad8a2e7e020901ddb74c3404a1c339b5a99f9.tar.gz rails-e2bad8a2e7e020901ddb74c3404a1c339b5a99f9.tar.bz2 rails-e2bad8a2e7e020901ddb74c3404a1c339b5a99f9.zip |
No need to create a variables to use them once.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/validations/uniqueness.rb | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb index 3eba7510ac..853808eebf 100644 --- a/activerecord/lib/active_record/validations/uniqueness.rb +++ b/activerecord/lib/active_record/validations/uniqueness.rb @@ -14,17 +14,14 @@ module ActiveRecord def validate_each(record, attribute, value) finder_class = find_finder_class_for(record) - table = finder_class.unscoped - - table_name = record.class.quoted_table_name if value && record.class.serialized_attributes.key?(attribute.to_s) value = YAML.dump value end - sql, params = mount_sql_and_params(finder_class, table_name, attribute, value) + sql, params = mount_sql_and_params(finder_class, record.class.quoted_table_name, attribute, value) - relation = table.where(sql, *params) + relation = finder_class.unscoped.where(sql, *params) Array.wrap(options[:scope]).each do |scope_item| scope_value = record.send(scope_item) |