# Odd to\_a deprecation message when calling association.include?(polymorphic object)

**URL:** <https://www.ruby-forum.com/t/odd-to-a-deprecation-message-when-calling-association-include-polymorphic-object/141562>\
**Category:** Rails\
**Created:** [June 27, 2008, 2:55am UTC](https://www.ruby-forum.com/t/odd-to-a-deprecation-message-when-calling-association-include-polymorphic-object/141562 "2008-06-27T02:55:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcarneiro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e36b37/32.png) [@dcarneiro](https://www.ruby-forum.com/u/dcarneiro)\
**Post date:** [June 27, 2008, 2:55am UTC](https://www.ruby-forum.com/t/odd-to-a-deprecation-message-when-calling-association-include-polymorphic-object/141562/1 "2008-06-27T02:55:14Z")

</div>

I’ve been getting the follow deprecation message a lot since upgrading  
to 2.1

/Users/choi/prx/vendor/rails/activerecord/lib/active\_record/  
associations/association\_proxy.rb:184: warning: default `to\_a’ will be  
obsolete

Digging around, I found out it was caused by this code (abbreviated)

> belongs\_to :purchased, :polymorphic =\> true  
> …  
> piece = purchased  
> purchaser\_account.licensed\_pieces.include?(piece)

A purchaser\_account has\_many licensed\_pieces.

But if I change the code to this, no deprecation warning results:

> belongs\_to :purchased, :polymorphic =\> true  
> …  
> piece = purchased  
> piece = Piece.find(piece.id) \<---- get the piece afresh apart from the polymorphic association  
> purchaser\_account.licensed\_pieces.include?(piece)

I don’t have time at the moment to dig through the Rails code to see  
why this is happening, but if anyone can tell me, I’d appreciate it!
