Forum: Ruby on Rails Raisl 2.2 and has_many_trough problems

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Hans M. (Guest)
on 2009-01-16 13:35
Have just installed rails 2.2.2 My application has many has_many_trough
associtions. With rails 2.2.2 I got an error trying to access some of
them

Event Model
  has_many :people,:through => :participants
  has_many :participants
Person Model
  has_many :events,:through => :participants
  has_many :participants
Table participants has the fields, event_id, person_id, role

Now when I try this test
    @event=Event.find(:first)
    @event.people.each {|person|  puts 'EVENT '+person.name}

I got the error stack level too deep (concerns method missing)
debugging shows that is is the method each that is missing.
More debugging shows that @event.people seems not to be an array
When I try puts  @event.people  I got the error can't
convertActiveRecord::Associations::HasManyThroughAssociation into String

I did not have that error in rails 2.0 and it shows up only for some
has_many ass
Anyone that has had the same problem ?
Any work-arounds ?
Thanks or any help
Frederick C. (Guest)
on 2009-01-16 16:12
(Received via mailing list)
On 16 Jan 2009, at 11:35, Hans M. wrote:

>  has_many :events,:through => :participants
>  has_many :participants
> Table participants has the fields, event_id, person_id, role
>

Do you need to create the :participants association before you create
associations through it ?

Fred
Hans M. (Guest)
on 2009-01-16 16:24
Frederick C. wrote:
> On 16 Jan 2009, at 11:35, Hans M. wrote:
>
>>  has_many :events,:through => :participants
>>  has_many :participants
>> Table participants has the fields, event_id, person_id, role
>>
>
> Do you need to create the :participants association before you create
> associations through it ?
>
> Fred

What do you mean with before ?
However I changed the order to

has_many :participants
has_many :events,:through => :participants

And that does not solve the problem

After som more debugging it seems like all my HasManyThroughAssociation
have the same problem
Hans M. (Guest)
on 2009-01-16 19:08
Problem solved !!!!!!!!!!!!!
====================
I have now made a lot more debugging that showed that the bad code was
the plugin will paginate. I had an old version and when I updated to the
last version (for rails 2.2.2) of will paginate everything works fine
again.

The lesson learned. Always update your plugins when you update rails
!!!!!!!!
This topic is locked and can not be replied to.