aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
authorMehmet Emin İNAÇ <mehmetemininac@gmail.com>2015-07-12 03:03:05 +0300
committerMehmet Emin İNAÇ <mehmetemininac@gmail.com>2015-07-22 00:51:23 +0300
commit4f1ec3ac96d4593063603306d2548e0206124d5c (patch)
tree52f4969acad2b611f410e6bcf527794e6f03b3e2 /activerecord/lib/active_record/associations
parentefd2410b3973671f430f04a9ca1501d38b53acf0 (diff)
downloadrails-4f1ec3ac96d4593063603306d2548e0206124d5c.tar.gz
rails-4f1ec3ac96d4593063603306d2548e0206124d5c.tar.bz2
rails-4f1ec3ac96d4593063603306d2548e0206124d5c.zip
Fix misleading errors for has_one through relations
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/through_association.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/through_association.rb b/activerecord/lib/active_record/associations/through_association.rb
index 55ee9f04e0..d0ec3e8015 100644
--- a/activerecord/lib/active_record/associations/through_association.rb
+++ b/activerecord/lib/active_record/associations/through_association.rb
@@ -76,13 +76,21 @@ module ActiveRecord
def ensure_mutable
unless source_reflection.belongs_to?
- raise HasManyThroughCantAssociateThroughHasOneOrManyReflection.new(owner, reflection)
+ if reflection.has_one?
+ raise HasOneThroughCantAssociateThroughHasOneOrManyReflection.new(owner, reflection)
+ else
+ raise HasManyThroughCantAssociateThroughHasOneOrManyReflection.new(owner, reflection)
+ end
end
end
def ensure_not_nested
if reflection.nested?
- raise HasManyThroughNestedAssociationsAreReadonly.new(owner, reflection)
+ if reflection.has_one?
+ raise HasOneThroughNestedAssociationsAreReadonly.new(owner, reflection)
+ else
+ raise HasManyThroughNestedAssociationsAreReadonly.new(owner, reflection)
+ end
end
end