Eager loading has_many through

hi all,

My relationships:

  • group habtm user and
  • user has_many events :through statistics.
    The statistics contains the id of user and is of event and additional
    data.

How can I get all the users in a group with their statistics via eager
loading.

I tried:
@users = a_node.users.find(:all, :include => :statistics, :conditions
=> [“statistics.event_id = ?”, event.id])

The problem is that I only get the users with a statistics record and
I also want users without any stastics. I think the problem is caused
by :conditions => [“statistics.event_id = ?”, event.id] but I don’t
know how to include the event_id in another way.

Someone can help me out?

Thanks
-Stijn

:include => [:statistics, :events] or :include => “:statistics, :events”

No?

On Jan 30, 2008 9:28 AM, Tarscher [email protected] wrote:

loading.
Someone can help me out?

Thanks
-Stijn


Ryan B.
http://www.frozenplague.net
Feel free to add me to MSN and/or GTalk as this email.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs