# Associazioni polimorfiche: Sono estensibili?

**URL:** <https://www.ruby-forum.com/t/associazioni-polimorfiche-sono-estensibili/149959>\
**Category:** IT\
**Created:** [October 1, 2008, 6:02pm UTC](https://www.ruby-forum.com/t/associazioni-polimorfiche-sono-estensibili/149959 "2008-10-01T18:02:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![carminem](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/90db22/32.png) [@carminem](https://www.ruby-forum.com/u/carminem)\
**Post date:** [October 1, 2008, 6:02pm UTC](https://www.ruby-forum.com/t/associazioni-polimorfiche-sono-estensibili/149959/1 "2008-10-01T18:02:21Z")

</div>

Salve a tutti;

Ho un modello con il codice seguente:

has\_one :attachment, :as =\> :attachable, :dependent =\> :destroy do  
def logo  
find(:first, :conditions =\> [‘content\_type = ?’, ‘image/jpeg’])  
end  
end

Supponendo di aver giÃ popolato l’attachment del modello, se cerco di  
accedere con:

istanza.attachment.logo

ottengo un “NoMethodError: undefined method ‘logo’ for #\<Attachment…”

PerchÃ¨?

In un altro modello ho:

has\_many :orders do  
def submitted  
find(:all, :conditions =\> [“status = ?”,‘submitted’])  
end

```
def shipped
  find(:all, :conditions => ["status = ?",'shipped'])
end

def cancelled
  find(:all, :conditions => ["status = ?",'cancelled'])
end

```

end

E non si presenta alcun problema nell’accedere a “orders.submitted” &  
Co.

Non Ã¨ possibile estendere le associazioni polimorfiche?

Grazie in anticipo per il Vs aiuto
