# Another Engines 2.0 problem

**URL:** <https://www.ruby-forum.com/t/another-engines-2-0-problem/125118>\
**Category:** Engines\
**Created:** [January 5, 2008, 7:47pm UTC](https://www.ruby-forum.com/t/another-engines-2-0-problem/125118 "2008-01-05T19:47:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_Schofield](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/22d042/32.png) [@Sean\_Schofield](https://www.ruby-forum.com/u/Sean_Schofield)\
**Post date:** [January 5, 2008, 7:47pm UTC](https://www.ruby-forum.com/t/another-engines-2-0-problem/125118/1 "2008-01-05T19:47:09Z")

</div>

I’m having a brand new problem that seems to be caused by either  
Engines 2.0 and/or Rails 2.0.2. Everything was working fine until I  
upgraded both of these. I’m getting this message when I refresh a  
page.

A copy of Tag has been removed from the module tree but is still active!

This looks like a similar problem to a previous post[1] on this forum.  
In particular this line from that post seems relevant:

“Engines now rely on Rails’ own plugin  
mechanisms. I seem to remember that I’ve seen an error like this when  
references to a class are saved somewhere and the class then gets  
reloaded in development mode while the reference holding object  
doesn’t.”

I guess I could use some more information on how things were changed.  
I don’t know much about the loading mechanism of Rails yet so I’m at a  
loss as to how to fix it. The Tag stuff comes from  
has\_many\_polymorphs. Tag is a model defined in the main application  
and Product is a model defined in the plugin. I suspect this might be  
the problem but I have no idea how to go about fixing it.

TIA,

Sean

[1] [Engines 2.0/trunk with Rails 2.0 - Engines Development - Ruby-Forum](http://www.ruby-forum.com/topic/134839)

---

<div class="post-metadata">

**Author:** ![Sean\_Schofield](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/22d042/32.png) [@Sean\_Schofield](https://www.ruby-forum.com/u/Sean_Schofield)\
**Post date:** [January 5, 2008, 8:48pm UTC](https://www.ruby-forum.com/t/another-engines-2-0-problem/125118/2 "2008-01-05T20:48:40Z")

</div>

This problem normally indicates that Rails’ dependencies are trying to  
reload a class, but a reference to the class is maintained by another  
object which isn’t reloaded. In this case, it could be that your  
Product model refers to Tag, and we hit the error when Tag reloads.

You might try making your Product model reloadable (require it via  
require\_dependency, rather than relying on Rails’ autoloading)?

---

<div class="post-metadata">

**Author:** ![Sean\_Schofield](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/22d042/32.png) [@Sean\_Schofield](https://www.ruby-forum.com/u/Sean_Schofield)\
**Post date:** [January 5, 2008, 9:43pm UTC](https://www.ruby-forum.com/t/another-engines-2-0-problem/125118/3 "2008-01-05T21:43:43Z")

</div>

I had this problem too, I think it’s because rails doesn’t reload plugin  
classes by default now. Somehow that ends up causing the crash here.  
Definitely one of the more annoying crashes because it’s nothing obvious  
with your code.

I talked to one of the rails guys a bit in this ticket,  
[http://dev.rubyonrails.org/ticket/10488](http://dev.rubyonrails.org/ticket/10488)

And his suggestion here worked:

- Add an after\_initialize hook in your development environment:

config.after\_initialize {  
Dependencies.load\_once\_paths = []  
}

-Andrew

---

<div class="post-metadata">

**Author:** ![Sean\_Schofield](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/22d042/32.png) [@Sean\_Schofield](https://www.ruby-forum.com/u/Sean_Schofield)\
**Post date:** [January 6, 2008, 10:18am UTC](https://www.ruby-forum.com/t/another-engines-2-0-problem/125118/4 "2008-01-06T10:18:24Z")

</div>

Am 05.01.2008 um 21:43 schrieb Andrew R.:

> config.after\_initialize {  
> Dependencies.load\_once\_paths = []  
> }

Amazing. That’s a nice tip.

Thanks!

–  
sven fuchs removed\_email\_address@domain.invalid  
artweb design [http://www.artweb-design.de](http://www.artweb-design.de)  
grünberger 65 + 49 (0) 30 - 47 98 69 96 (phone)  
d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile)
