# Rails2.0 not reloading engine controllers/models

**URL:** <https://www.ruby-forum.com/t/rails2-0-not-reloading-engine-controllers-models/122834>\
**Category:** Engines Development\
**Created:** [December 12, 2007, 6:20pm UTC](https://www.ruby-forum.com/t/rails2-0-not-reloading-engine-controllers-models/122834 "2007-12-12T18:20:39Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/u/ArtSSSSras_SSSSlaju)\
**Post date:** [December 12, 2007, 6:20pm UTC](https://www.ruby-forum.com/t/rails2-0-not-reloading-engine-controllers-models/122834/1 "2007-12-12T18:20:39Z")

</div>

Hello,

Rails 2.0.1 does not reload engine-based plugin controllers and models  
in development mode.

You have to restart mongrel to get them reloaded.

Anyone else has this issue?

---

<div class="post-metadata">

**Author:** ![ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/u/ArtSSSSras_SSSSlaju)\
**Post date:** [December 12, 2007, 6:37pm UTC](https://www.ruby-forum.com/t/rails2-0-not-reloading-engine-controllers-models/122834/2 "2007-12-12T18:37:54Z")

</div>

Hi,

it works for me.

But generally, classes that are loaded through dependency autoloading  
during the plugin load process (i.e. init.rb evaluation) won’t be  
reloaded for subsequent requests in dev mode.

[http://weblog.techno-weenie.net/2007/1/26/understanding-the-rails-plugin-initialization-process](http://weblog.techno-weenie.net/2007/1/26/understanding-the-rails-plugin-initialization-process)

(IMO this is a really annoying feature and it’s a pitty that it hasn’t  
been revisited in Rails 2.0)

If this is related to your problem you can try to remove the affected  
directories from Dependencies.load\_once\_paths like:

Dependencies.load\_once\_paths.delete(path)

Or try not to load them during the plugin loading stage …

Am 12.12.2007 um 17:41 schrieb ArtÅ«ras Å lajus:

> Engine-Developers mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org](http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org)

–  
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)

---

<div class="post-metadata">

**Author:** ![ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/u/ArtSSSSras_SSSSlaju)\
**Post date:** [December 12, 2007, 6:52pm UTC](https://www.ruby-forum.com/t/rails2-0-not-reloading-engine-controllers-models/122834/3 "2007-12-12T18:52:51Z")

</div>

I’m not sure that Rails has ever allowed automatic reloading of code  
from plugins in development - can anyone confirm this?

---

<div class="post-metadata">

**Author:** ![ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/u/ArtSSSSras_SSSSlaju)\
**Post date:** [December 12, 2007, 9:24pm UTC](https://www.ruby-forum.com/t/rails2-0-not-reloading-engine-controllers-models/122834/4 "2007-12-12T21:24:25Z")

</div>

Sven F. wrote:

> Hi,
> 
> it works for me.
> 
> But generally, classes that are loaded through dependency autoloading  
> during the plugin load process (i.e. init.rb evaluation) won’t be  
> reloaded for subsequent requests in dev mode.

i wasn’t talking about those, i was talking about  
vendor/plugins/your\_plugin/app/models/foo.rb (same with controllers)

It used to work perfectly with 1.2, now it just loads them once ☹

---

<div class="post-metadata">

**Author:** ![ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/u/ArtSSSSras_SSSSlaju)\
**Post date:** [December 12, 2007, 7:26pm UTC](https://www.ruby-forum.com/t/rails2-0-not-reloading-engine-controllers-models/122834/5 "2007-12-12T19:26:37Z")

</div>

Am 12.12.2007 um 17:55 schrieb Sven F.:

> it works for me.

Whoops, sorry.

It works for me in an outdated version that I’m still using for a  
client … but it doesn’t seem to work with the current trunk (which  
is, IMO, correct).

Am 12.12.2007 um 18:51 schrieb James A.:

> I’m not sure that Rails has ever allowed automatic reloading of code  
> from plugins in development - can anyone confirm this?

Yes, I think this is true.

They once tried to change it, but ran into issues with plugins that  
rely on their classes not being auto-reloaded and thus invented  
Dependencies.load\_once\_paths. See Rick’s post on this:  
[http://weblog.techno-weenie.net/2007/1/26/understanding-the-rails-plugin-initialization-process](http://weblog.techno-weenie.net/2007/1/26/understanding-the-rails-plugin-initialization-process)

I strongly believe that this is the wrong approach to it though, as it  
leads to all kinds of weird side-effects. A better approach to it  
would be to whitelist those plugins that don’t want to be auto-  
reloaded but auto-reload everything else. (Actually there’s even a  
config.load\_once\_paths feature that would allow to do this.)

–  
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)

---

<div class="post-metadata">

**Author:** ![ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/u/ArtSSSSras_SSSSlaju)\
**Post date:** [December 12, 2007, 10:18pm UTC](https://www.ruby-forum.com/t/rails2-0-not-reloading-engine-controllers-models/122834/6 "2007-12-12T22:18:04Z")

</div>

Sven F. wrote:

> # somewhere
> 
> Rails::Plugin.class\_eval do  
> def reloadable!  
> load\_paths.each { |p| Dependencies.load\_once\_paths.delete§ }  
> end  
> end
> 
> # in your plugin init.rb
> 
> reloadable!

evil, evil hack 😑

thanks thou…

they could make vendor/plugins/load\_once/ and vendor/plugins/reloadable  
…

perhaps i’ll make a patch and fix it! =) it would be cool 🙂

what do you think of this idea?

---

<div class="post-metadata">

**Author:** ![ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/u/ArtSSSSras_SSSSlaju)\
**Post date:** [December 12, 2007, 10:54pm UTC](https://www.ruby-forum.com/t/rails2-0-not-reloading-engine-controllers-models/122834/7 "2007-12-12T22:54:32Z")

</div>

Am 12.12.2007 um 22:17 schrieb ArtÅ«ras Å lajus:

> > reloadable!  
> > evil, evil hack 😑

Well it’s the technique that Rick O. suggested, who also seems to  
be the one who implemented that whole load\_once\_paths thing (not  
totally sure though).

So I think this is the “official” way of forcing the framework to  
reload your plugin classes.

> thanks thou…
> 
> they could make vendor/plugins/load\_once/ and vendor/plugins/  
> reloadable  
> …
> 
> perhaps i’ll make a patch and fix it! =) it would be cool 🙂

Where would you patch that?

Actually I don’t know enough about the context and history of that  
feature to judge that. But I’ll try and keep nagging on Rick to  
finally fix that thing in Rails core. I think everything that raises  
awareness about this might be a potential move forward.

–  
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)

---

<div class="post-metadata">

**Author:** ![ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/u/ArtSSSSras_SSSSlaju)\
**Post date:** [December 12, 2007, 10:11pm UTC](https://www.ruby-forum.com/t/rails2-0-not-reloading-engine-controllers-models/122834/8 "2007-12-12T22:11:36Z")

</div>

Am 12.12.2007 um 21:23 schrieb ArtÅ«ras Å lajus:

> i wasn’t talking about those, i was talking about  
> vendor/plugins/your\_plugin/app/models/foo.rb (same with controllers)

Yes, like I said in the other mail I mistakenly looked at an outdated  
version. You’re right that this isn’t going to work by default.

> It used to work perfectly with 1.2, now it just loads them once ☹

That might have to do with the fact that Engines now uses the new  
plugin architecture that’s implemented in Rails 2.0 rather than  
shipping it’s own stuff.

Rails makes it so that your plugin load paths are added to  
Dependencies.load\_once\_paths which means that those classes aren’t  
reloaded.

You can remove them from there, though:

# somewhere

Rails::Plugin.class\_eval do  
def reloadable!  
load\_paths.each { |p| Dependencies.load\_once\_paths.delete(p) }  
end  
end

# in your plugin init.rb

reloadable!

–  
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)

---

<div class="post-metadata">

**Author:** ![ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/u/ArtSSSSras_SSSSlaju)\
**Post date:** [December 12, 2007, 11:08pm UTC](https://www.ruby-forum.com/t/rails2-0-not-reloading-engine-controllers-models/122834/9 "2007-12-12T23:08:38Z")

</div>

Sven F. wrote:

> Actually I don’t know enough about the context and history of that  
> feature to judge that. But I’ll try and keep nagging on Rick to  
> finally fix that thing in Rails core. I think everything that raises  
> awareness about this might be a potential move forward.

Here goes simple but usefull solution!

— rails-2.0.1/lib/rails/plugin/loader.orig.rb 2007-12-13  
00:01:38.000000000 +0200  
+++ rails-2.0.1/lib/rails/plugin/loader.rb 2007-12-13  
00:11:19.000000000 +0200  
@@ -42,11 +42,14 @@  
#  
# Plugin load paths are also added to Dependencies.load\_paths,  
and Dependencies.load\_once\_paths.  
def add\_plugin\_load\_paths

- 

```
   reloadable_path = File.join('vendor', 'plugins', 'reloadable')
    plugins.each do |plugin|
      plugin.load_paths.each do |path|
        $LOAD_PATH.insert(application_lib_index + 1, path)
        Dependencies.load_paths << path

```

- 

```
       Dependencies.load_once_paths << path

```

- 

```
       if path.index(reloadable_path).nil?

```

- 

```
         Dependencies.load_once_paths << path

```

- 

```
       end
      end
    end
    $LOAD_PATH.uniq!

```

@@ -147,4 +150,4 @@

```
  end
end

```

-end  
\ No newline at end of file  
+end

And here it’s in all its glory 🙂

> > pp Dependencies.load\_paths - Dependencies.load\_once\_paths  
> > ["/home/x11/www/rails/vk-diplominis/test/mocks/development",  
> > “/home/x11/www/rails/vk-diplominis/app/controllers/”,  
> > “/home/x11/www/rails/vk-diplominis/app”,  
> > “/home/x11/www/rails/vk-diplominis/app/models”,  
> > “/home/x11/www/rails/vk-diplominis/app/controllers”,  
> > “/home/x11/www/rails/vk-diplominis/app/helpers”,  
> > “/home/x11/www/rails/vk-diplominis/components”,  
> > “/home/x11/www/rails/vk-diplominis/config”,  
> > “/home/x11/www/rails/vk-diplominis/lib”,  
> > “/home/x11/www/rails/vk-diplominis/vendor”,  
> > “/var/lib/gems/1.8/gems/rails-2.0.1/lib/…/builtin/rails\_info/”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/user\_login\_engine/app/controllers”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/user\_login\_engine/app/helpers”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/user\_login\_engine/app/models”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/user\_login\_engine/lib”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/datepicker/lib”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/flash\_divs/lib”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/gallery\_engine/app/controllers”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/gallery\_engine/app/helpers”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/gallery\_engine/app/models”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/gallery\_engine/lib”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/groups\_engine/app/controllers”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/groups\_engine/app/helpers”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/groups\_engine/app/models”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/groups\_engine/lib”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/hex\_encoder/lib”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/user\_communication\_engine/app/controllers”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/user\_communication\_engine/app/helpers”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/user\_communication\_engine/app/models”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/user\_communication\_engine/lib”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/user\_profiles\_engine/app/controllers”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/user\_profiles\_engine/app/helpers”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/user\_profiles\_engine/app/models”,  
> > “/home/x11/www/rails/vk-diplominis/vendor/plugins/reloadable/user\_profiles\_engine/lib”]

Isn’t that just cool? 🙂

---

<div class="post-metadata">

**Author:** ![ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/u/ArtSSSSras_SSSSlaju)\
**Post date:** [December 12, 2007, 11:10pm UTC](https://www.ruby-forum.com/t/rails2-0-not-reloading-engine-controllers-models/122834/10 "2007-12-12T23:10:59Z")

</div>

err, a tiny weak to use String#include? not #index

— rails-2.0.1/lib/rails/plugin/loader.orig.rb 2007-12-13  
00:01:38.000000000 +0200  
+++ rails-2.0.1/lib/rails/plugin/loader.rb 2007-12-13  
00:15:49.000000000 +0200  
@@ -42,11 +42,14 @@  
#  
# Plugin load paths are also added to Dependencies.load\_paths,  
and Dependencies.load\_once\_paths.  
def add\_plugin\_load\_paths

- 

```
   reloadable_path = File.join('vendor', 'plugins', 'reloadable')
    plugins.each do |plugin|
      plugin.load_paths.each do |path|
        $LOAD_PATH.insert(application_lib_index + 1, path)
        Dependencies.load_paths << path

```

- 

```
       Dependencies.load_once_paths << path

```

- 

```
       unless path.include? reloadable_path

```

- 

```
         Dependencies.load_once_paths << path

```

- 

```
       end
      end
    end
    $LOAD_PATH.uniq!

```

@@ -147,4 +150,4 @@

```
  end
end

```

-end  
\ No newline at end of file  
+end

---

<div class="post-metadata">

**Author:** ![ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/u/ArtSSSSras_SSSSlaju)\
**Post date:** [December 14, 2007, 9:40am UTC](https://www.ruby-forum.com/t/rails2-0-not-reloading-engine-controllers-models/122834/11 "2007-12-14T09:40:40Z")

</div>

ArtÅ«ras Å lajus wrote:

> Sven F. wrote:
> 
> > Where would you patch that?
> 
> [http://dev.rubyonrails.org/ticket/10488](http://dev.rubyonrails.org/ticket/10488)

no comments? ☹

---

<div class="post-metadata">

**Author:** ![ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/u/ArtSSSSras_SSSSlaju)\
**Post date:** [December 14, 2007, 10:52am UTC](https://www.ruby-forum.com/t/rails2-0-not-reloading-engine-controllers-models/122834/12 "2007-12-14T10:52:50Z")

</div>

Hi ArtÅ«ras!

Sorry I have missed that one.

Am 14.12.2007 um 09:37 schrieb ArtÅ«ras Å lajus:

> ArtÅ«ras Å lajus wrote:
> 
> > Sven F. wrote:
> > 
> > > Where would you patch that?
> > 
> > [http://dev.rubyonrails.org/ticket/10488](http://dev.rubyonrails.org/ticket/10488)

Hey, that really was a quick shot 🙂

Personally I tend to discus stuff like this first and then propose a  
patch. But I already learned that this isn’t always the way to go 😉

I think it’s a good idea!

But it has the drawback that it nails things to a very specific  
concern. Maybe folks want to organize their plugins in a different  
way? I’m working for a client who most probably would not want to use  
this directory layout because he already structures things by other  
criteria.

That said, I think it’s _really_ useful to generate some fuss around  
this topic. It might take ages to even get heard by some rails-core  
member as they don’t seem to use plugins that much anyways.

–  
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)

---

<div class="post-metadata">

**Author:** ![ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/u/ArtSSSSras_SSSSlaju)\
**Post date:** [December 12, 2007, 11:36pm UTC](https://www.ruby-forum.com/t/rails2-0-not-reloading-engine-controllers-models/122834/13 "2007-12-12T23:36:16Z")

</div>

Sven F. wrote:

> Where would you patch that?

[http://dev.rubyonrails.org/ticket/10488](http://dev.rubyonrails.org/ticket/10488)

---

<div class="post-metadata">

**Author:** ![ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/u/ArtSSSSras_SSSSlaju)\
**Post date:** [January 25, 2008, 12:26pm UTC](https://www.ruby-forum.com/t/rails2-0-not-reloading-engine-controllers-models/122834/14 "2008-01-25T12:26:46Z")

</div>

Hmmm. Something’s occurred to me.

With the implementation of engines 1.1.x, the app/models directory  
wasn’t involved dur the plugin loading process, which meant that it  
wouldn’t be added to load\_once\_paths.

However, with 2.x, we’re now hooking into a plugin-generic load\_paths  
mechanism, which means that paths we add to the $LOAD\_PATH via this  
are candidates for inclusion in load\_once\_paths.

This could explain why reloading classes from plugins (well, from  
app/models) used to be easier, but now requires some extra steps.

Does this make sense? I’m not sure that there’s an ideal solution,  
unfortunately - Rails probably wants to keep the notion of  
“load\_once\_paths”, and reverting the behaviour of the engines plugin  
makes it significantly more complicated.

I’m curious about which plugins might break without load\_once\_paths…

---

<div class="post-metadata">

**Author:** ![ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/u/ArtSSSSras_SSSSlaju)\
**Post date:** [January 25, 2008, 11:26am UTC](https://www.ruby-forum.com/t/rails2-0-not-reloading-engine-controllers-models/122834/15 "2008-01-25T11:26:10Z")

</div>

On Wed, Dec 12, 2007 at 05:51:48PM +0000, James A. wrote:

> I’m not sure that Rails has ever allowed automatic reloading of code  
> from plugins in development - can anyone confirm this?

No idea about Rails, but with Engines in 1.x it used to Just Work.

What’s even worse is that if you include engines and load a model from  
an engine in your app’s model, it gets marked unreloadable, too!  
So if you have

app/models/user.rb

require\_dependency(File.join(RAILS\_ROOT,  
“vendor/plugins/accounts/app/models/user.rb”))

class User \< ActiveRecord::Base  
…  
end

and you change something in there, you will need to restart your server,  
too!  
This really makes it unusable, IMHO.

Right now I’m just hacking around it by putting  
Dependencies.load\_once\_paths = []  
in my environment.rb. It’s a hack, but without it really really sucks.

Cheers,  
Peter B.  
Solide ICT - [http://www.solide-ict.nl](http://www.solide-ict.nl)

---

<div class="post-metadata">

**Author:** ![ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/u/ArtSSSSras_SSSSlaju)\
**Post date:** [January 25, 2008, 1:40pm UTC](https://www.ruby-forum.com/t/rails2-0-not-reloading-engine-controllers-models/122834/16 "2008-01-25T13:40:54Z")

</div>

Am 25.01.2008 um 12:26 schrieb James A.:

> This could explain why reloading classes from plugins (well, from  
> app/models) used to be easier, but now requires some extra steps.
> 
> Does this make sense?

Absolutely. I’m pretty sure this is the reason for this kind of  
behaviour.

> I’m not sure that there’s an ideal solution,  
> unfortunately - Rails probably wants to keep the notion of  
> “load\_once\_paths”, and reverting the behaviour of the engines plugin  
> makes it significantly more complicated.

IMO there’s no sane reason as to why plugins and libs should behave  
differently from any app model class _by default_. It’s not only  
counterintuitive but leads to major issues when one tries to work  
around it.

I’ve talked to Rick O. briefly about this issue on IRC and he  
agreed that this behaviour not only sucks but also might be something  
that should be changed in some future major Rails release (like Rails  
3.0).

> I’m curious about which plugins might break without load\_once\_paths…

Me too.

Reportedly there are quite some plugins that rely on the behaviour of  
plugins not being reloaded. Thus it would be kind of an “political”  
issue to change this and break “lots of plugins”.

Maybe you’re somebody who could raise this question on Rails core?

> > from  
> > end  
> > Cheers,
> 
> - J \*  
> ~
> 
> * * *
> 
> Engine-Developers mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org](http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org)

–  
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)

---

<div class="post-metadata">

**Author:** ![ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ArtSSSSras\_SSSSlaju](https://www.ruby-forum.com/u/ArtSSSSras_SSSSlaju)\
**Post date:** [January 25, 2008, 1:06pm UTC](https://www.ruby-forum.com/t/rails2-0-not-reloading-engine-controllers-models/122834/17 "2008-01-25T13:06:43Z")

</div>

On Fri, Jan 25, 2008 at 11:26:15AM +0000, James A. wrote:

> This could explain why reloading classes from plugins (well, from  
> app/models) used to be easier, but now requires some extra steps.
> 
> Does this make sense?

Sounds logical.

> I’m not sure that there’s an ideal solution,  
> unfortunately - Rails probably wants to keep the notion of  
> “load\_once\_paths”, and reverting the behaviour of the engines plugin  
> makes it significantly more complicated.

Maybe we can somehow hack Rails::Plugin::Loader#add\_plugin\_load\_paths  
to exclude any paths added by engines, then we’re good. I don’t know  
if Engines can currently distinguish between an Engine and a regular  
plugin, though.

> I’m curious about which plugins might break without load\_once\_paths…

I think a lot will fail. Simply commenting out the line in the above  
mentioned module gave me a stack overflow somewhere in  
pluginify\_sources.  
However, after retrying another time I didn’t get this error.  
Maybe the plugin\_load\_once\_paths is an attempt to cover up some bug  
in Rails’ autoloading system?

Cheers,  
Peter B.  
Solide ICT - [http://www.solide-ict.nl](http://www.solide-ict.nl)
