aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/validations
diff options
context:
space:
mode:
authorEvgeny Li <exaspark@gmail.com>2013-11-05 18:36:48 +0400
committerEvgeny Li <exaspark@gmail.com>2013-11-22 22:22:34 +0400
commitc449a74e8944eed75453963288ea7a8652f5ba93 (patch)
treee4c490f06fe5714c523a93b839a2e7d1c9352bb8 /activerecord/lib/active_record/validations
parent34c08d2ead9360e1d9577dbc491d221ab66a2151 (diff)
downloadrails-c449a74e8944eed75453963288ea7a8652f5ba93.tar.gz
rails-c449a74e8944eed75453963288ea7a8652f5ba93.tar.bz2
rails-c449a74e8944eed75453963288ea7a8652f5ba93.zip
Fix validation on uniqueness of empty association
Diffstat (limited to 'activerecord/lib/active_record/validations')
-rw-r--r--activerecord/lib/active_record/validations/uniqueness.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb
index b55af692d6..38f37f5c8a 100644
--- a/activerecord/lib/active_record/validations/uniqueness.rb
+++ b/activerecord/lib/active_record/validations/uniqueness.rb
@@ -48,7 +48,7 @@ module ActiveRecord
def build_relation(klass, table, attribute, value) #:nodoc:
if reflection = klass.reflect_on_association(attribute)
attribute = reflection.foreign_key
- value = value.attributes[reflection.primary_key_column.name]
+ value = value.attributes[reflection.primary_key_column.name] unless value.nil?
end
column = klass.columns_hash[attribute.to_s]