Raisl 2.2 and has_many_trough problems


#1

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


#2

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


#3

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


#4

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
!!!