diff options
author | Eileen M. Uchitelle <eileencodes@gmail.com> | 2016-08-05 16:41:45 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-05 16:41:45 -0400 |
commit | 53607c8e9fd74e0bc3925e940583d97429e88266 (patch) | |
tree | 46f6ee56b6c67ca57385f8ff758f7d039b7bde55 /activerecord/lib | |
parent | 2bd9ec6b3da82e5519baab787d42997c50c93c73 (diff) | |
parent | f3cb1f8a597b3b30fdc7a39dcbe38b123a38144d (diff) | |
download | rails-53607c8e9fd74e0bc3925e940583d97429e88266.tar.gz rails-53607c8e9fd74e0bc3925e940583d97429e88266.tar.bz2 rails-53607c8e9fd74e0bc3925e940583d97429e88266.zip |
Merge pull request #25665 from kamipo/remove_unused_table_arg
Remove unused `table` arg for `UniquenessValidator#scope_relation`
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/validations/uniqueness.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb index ec9f498c40..608d072e48 100644 --- a/activerecord/lib/active_record/validations/uniqueness.rb +++ b/activerecord/lib/active_record/validations/uniqueness.rb @@ -12,10 +12,9 @@ module ActiveRecord def validate_each(record, attribute, value) finder_class = find_finder_class_for(record) - table = finder_class.arel_table value = map_enum_attribute(finder_class, attribute, value) - relation = build_relation(finder_class, table, attribute, value) + relation = build_relation(finder_class, attribute, value) if record.persisted? if finder_class.primary_key relation = relation.where.not(finder_class.primary_key => record.id_was || record.id) @@ -23,7 +22,7 @@ module ActiveRecord raise UnknownPrimaryKey.new(finder_class, "Can not validate uniqueness for persisted record without primary key.") end end - relation = scope_relation(record, table, relation) + relation = scope_relation(record, relation) relation = relation.merge(options[:conditions]) if options[:conditions] if relation.exists? @@ -50,7 +49,7 @@ module ActiveRecord class_hierarchy.detect { |klass| !klass.abstract_class? } end - def build_relation(klass, table, attribute, value) #:nodoc: + def build_relation(klass, attribute, value) # :nodoc: if reflection = klass._reflect_on_association(attribute) attribute = reflection.foreign_key value = value.attributes[reflection.klass.primary_key] unless value.nil? @@ -63,6 +62,7 @@ module ActiveRecord attribute_name = attribute.to_s + table = klass.arel_table column = klass.columns_hash[attribute_name] cast_type = klass.type_for_attribute(attribute_name) @@ -80,7 +80,7 @@ module ActiveRecord end end - def scope_relation(record, table, relation) + def scope_relation(record, relation) Array(options[:scope]).each do |scope_item| if reflection = record.class._reflect_on_association(scope_item) scope_value = record.send(reflection.foreign_key) |