# Problema con :include e modelli nn direttamente associati

**URL:** <https://www.ruby-forum.com/t/problema-con-include-e-modelli-nn-direttamente-associati/119482>\
**Category:** IT\
**Created:** [November 7, 2007, 10:45am UTC](https://www.ruby-forum.com/t/problema-con-include-e-modelli-nn-direttamente-associati/119482 "2007-11-07T10:45:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stratboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/838e76/32.png) [@stratboy](https://www.ruby-forum.com/u/stratboy)\
**Post date:** [November 7, 2007, 10:45am UTC](https://www.ruby-forum.com/t/problema-con-include-e-modelli-nn-direttamente-associati/119482/1 "2007-11-07T10:45:00Z")

</div>

ho questi modelli:  
class Event \< Core  
belongs\_to :user  
has\_many :event\_dates  
has\_and\_belongs\_to\_many :event\_type\_names  
end

class EventDate \< ActiveRecord::Base  
belongs\_to :event  
has\_and\_belongs\_to\_many :places,:foreign\_key =\> ‘event\_date\_id’,  
:association\_foreign\_key =\> ‘place\_id’  
end

class EventTypeName \< ActiveRecord::Base  
belongs\_to :event\_super\_type  
has\_and\_belongs\_to\_many :events  
end

- altri…  
Ora se eseguo queto metodo funziona:

dateeventi=EventDate.find(:all,  
:conditions=\>["? between date AND date\_add(date, INTERVAL  
number\_days DAY) AND (days\_of\_week=8 or  
days\_of\_week=?)",Date.today,(Date.today).wday],:include=\>[:event,:places]))

Se perÃ² nell’include inserisco anche :event\_type\_names in modo da nn  
eseguire una nuova query per ogni data di evento, non funziona.

Come devo fare?  
Grazie
