Missing assocation methods (public_instance_methods.length == 0 for an active record model)

Hi all,

I’m getting a weird “transient” error I’m hoping someone can shed some
light on.

In short, the first time view a particular page all is well. The
second time around, I get a bunch of active record model objects with
no public_instance_methods, so all code relying on that fails. Server
restart is required to fix it.

I have a method in one of my models that goes through several
associated models, iterates over the associated model objects and
further iterates into associated models on those to return some
distantly related model objects.

It works great… but only once for every server load. If I refresh the
page, subsequent calls to the accessor methods for the associations
have no methods!! So I get undefined method for something that clearly
existed just one refresh ago!

To give some more details, I have a Volunteer which has
VolunteerApplications which each have an Opportunity which each have
an Organization.

I want to get the organizations for a given volunteer… So I do so via

has_many :opportunities, :through => :volunteer_applications

which has created the opportunities method for me. I call that and
iterate over each and call organization on each (which was created by:
belongs_to :organization )

But upon refresh the organization accessor doesn’t exist for
opportunity, nor does any other.

Any clues? Ideas of how to better debug this? I’ve confirmed via
debugger that the attributes are all set on the model object, but it
has none of the association methods added by has_many, belongs_to,

I’ve also confirmed that belongs_to, etc are in fact being run.

Thanks in advance!
– Luke

I’d just like to add that this problem doesn’t occur in the test or
production environments, only development.
Also, we are running Rails 1.2.3 over Ruby 1.8.5


Once upon a time this would have involved using
model :blah

in the Controller… But I hear that’s deprecated. So I just required
the models… and it’s fine. Not an easy thing to troubleshoot though…

– Luke