Skip to content

Commit

Permalink
Verbose ActiveRecord::AssociationTypeMismatch exception message. [#189
Browse files Browse the repository at this point in the history
…state:resolved]
  • Loading branch information
lifo committed May 21, 2008
1 parent 281edce commit 19d7b1d
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -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

Expand Down

0 comments on commit 19d7b1d

Please sign in to comment.