On 19 nov, 11:57, Frederick Cheung <[EMAIL PROTECTED]> wrote:
> On 19 Nov 2008, at 10:47, Wincent Colaiuta wrote:
>
>
>
> > So somewhere between the evaluation of "config/environment.rb" and the
> > evaluation of the model file which uses the "acts_as_searchable"
> > method, the method is actually getting removed from
> > ActiveRecord::Base.
>
> > I am still digging around trying to find out why this is happening.
> > Anyone have any suggestions or ideas?
>
> I suspect that the difference is that in production mode on 2.2 models  
> are preloaded at the end of initialisation process, which is before  
> the stuff at the end of environment.rb gets run, ie your models are  
> loaded before you've required the file adding the stuff.

Thanks, Fred. Makes sense, but it doesn't explain the order in which I
see the debug statements get logged...

0. "inside environment.rb"
1. "requiring lib file"
2. "ActiveRecord::Base now includes the desired method"
3. "evaluating model file"
4. "ActiveRecord::Base does not include the desired method"

Must be some kind of anomaly caused by buffering or something which
makes the statements get echoed out of order (I haven't turned multi-
threading on so I understand that this should all be happening in a
single thread).

This is actually in the test environment because I'm testing this by
doing "rake spec".

I tried "script/server" in the development environment and it works;
tried it in production and I get the same failure.

I then added the following to config/environments/test.rb and config/
environments/production.rb and those environments now work again.

  config.cache_classes = false

So it works, but it seems like a bad idea to deploy with that
configuration due to the performance hit of reloading the classes with
every request.

I suppose there must be a better solution. Any suggestions?

Cheers,
Wincent
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to