# Engines' related Rails Development Mode errors (solved I think)

**URL:** <https://www.ruby-forum.com/t/engines-related-rails-development-mode-errors-solved-i-think/125117>\
**Category:** Engines\
**Created:** [January 5, 2008, 7:46pm UTC](https://www.ruby-forum.com/t/engines-related-rails-development-mode-errors-solved-i-think/125117 "2008-01-05T19:46:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pascal\_Rettig](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/848f3c/32.png) [@Pascal\_Rettig](https://www.ruby-forum.com/u/Pascal_Rettig)\
**Post date:** [January 5, 2008, 7:46pm UTC](https://www.ruby-forum.com/t/engines-related-rails-development-mode-errors-solved-i-think/125117/1 "2008-01-05T19:46:34Z")

</div>

Hi All,

I’m pretty new to Engines, but in upgrading a Rails application to 2.0  
I decided to move a bunch of modules from the deprecated “components”  
directory to a new “vendor/modules” directory and Engines seemed like  
the best drop-in replacement to do so.  
Everything was great in production mode, but in development mode I kept  
getting a bunch of strange errors of two different sorts:

- Method missing errors from Models that were defined in the code

- “A copy of XXX has been removed from the module tree but is still  
active!” errors for Application Controllers

This is probably old hat to people who have been using engines for a  
while, but I need to add the following to my init.rb to solve the  
issues:

load\_paths.each do |path|  
Dependencies.load\_once\_paths.delete(path)  
end

The reason for my issues is that I’m using the engine plugins in a way  
that they refer back to models and controllers in the main application,  
so they need to be reloaded in a similar method to the main application  
controllers & models or the class constant references will become stale  
on page refreshes.

Took me a couple hours of head banging on keyboard to figure this out so  
maybe this info will help someone else.

-Pascal

---

<div class="post-metadata">

**Author:** ![Pascal\_Rettig](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/848f3c/32.png) [@Pascal\_Rettig](https://www.ruby-forum.com/u/Pascal_Rettig)\
**Post date:** [January 5, 2008, 7:53pm UTC](https://www.ruby-forum.com/t/engines-related-rails-development-mode-errors-solved-i-think/125117/2 "2008-01-05T19:53:01Z")

</div>

Hey did you just read my email before posting that? If not, that was  
a scary coincidence.

Question about your solution … Which init.rb do you paste that code?  
In the engines plugin or the plugin that is relying on engines?

Sean

---

<div class="post-metadata">

**Author:** ![Pascal\_Rettig](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/848f3c/32.png) [@Pascal\_Rettig](https://www.ruby-forum.com/u/Pascal_Rettig)\
**Post date:** [January 5, 2008, 8:52pm UTC](https://www.ruby-forum.com/t/engines-related-rails-development-mode-errors-solved-i-think/125117/3 "2008-01-05T20:52:11Z")

</div>

My comments on this ticket might also be relevant -  
[http://dev.rubyonrails.org/ticket/10488#comment:6](http://dev.rubyonrails.org/ticket/10488#comment:6)

---

<div class="post-metadata">

**Author:** ![Pascal\_Rettig](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/848f3c/32.png) [@Pascal\_Rettig](https://www.ruby-forum.com/u/Pascal_Rettig)\
**Post date:** [January 5, 2008, 11:46pm UTC](https://www.ruby-forum.com/t/engines-related-rails-development-mode-errors-solved-i-think/125117/4 "2008-01-05T23:46:13Z")

</div>

Hi,

That is remarkable cross post, I didn’t see Sean’s message until just  
now.

> From the ticket James posted, I think the comment that plugins only need  
> to be reloaded during development is probably 99% true, except in  
> situations where the plugin refers to application classes by constant  
> (as opposed to something like ClassName.constantize) - which happens to  
> be my situation - in which case they will need to be reloadable in  
> development mode even after the plugin is no longer in development,  
> either via require\_dependency in the source app or removing it from the  
> load\_once list.  
> For engines, require\_dependency isn’t really a solution I don’t think as  
> pre-loading controllers would be a pain, especially with a bunch of  
> routes. Maybe just adding a function to Engines that has the same effect  
> as the code I posted would be enough.

The code I posted goes in the init.rb of the each plugin that needs to  
be marked as reloadable (not the engines plugin itself)

-Pascal
