Permalink
Browse files

Verbose ActiveRecord::AssociationTypeMismatch exception message. [#189

…state:resolved]
  • Loading branch information...
1 parent 281edce commit 19d7b1d22bd68af00244ddc3e1f35cec187e9120 @lifo lifo committed May 21, 2008
Showing with 2 additions and 1 deletion.
  1. +2 −1 activerecord/lib/active_record/associations/association_proxy.rb
@@ -210,7 +210,8 @@ def foreign_key_present
def raise_on_type_mismatch(record)
unless record.is_a?(@reflection.klass)
- raise ActiveRecord::AssociationTypeMismatch, "#{@reflection.klass} expected, got #{record.class}"
+ message = "#{@reflection.class_name}(##{@reflection.klass.object_id}) expected, got #{record.class}(##{record.class.object_id})"
+ raise ActiveRecord::AssociationTypeMismatch, message
end
end

0 comments on commit 19d7b1d

Please sign in to comment.