# Help: A copy of ModelSecurity has been removed from the module tree but is still active!

**URL:** <https://www.ruby-forum.com/t/help-a-copy-of-modelsecurity-has-been-removed-from-the-module-tree-but-is-still-active/148439>\
**Category:** Rails\
**Created:** [September 12, 2008, 9:16pm UTC](https://www.ruby-forum.com/t/help-a-copy-of-modelsecurity-has-been-removed-from-the-module-tree-but-is-still-active/148439 "2008-09-12T21:16:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bitsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9de053/32.png) [@bitsmith](https://www.ruby-forum.com/u/bitsmith)\
**Post date:** [September 12, 2008, 9:16pm UTC](https://www.ruby-forum.com/t/help-a-copy-of-modelsecurity-has-been-removed-from-the-module-tree-but-is-still-active/148439/1 "2008-09-12T21:16:08Z")

</div>

Hi all, I’m posting this in the hope that someone who understands  
rails dependencies can shed some light.

I’ve implemented a “ModelSecurity” module in the vein of Bruce Peren’s  
old ModelSecurity plugin ([http://rubyforge.org/projects/model-](http://rubyforge.org/projects/model-)  
security/).

My ModelSecurity module lives in $RAILS\_ROOT/lib. It is automatically  
included into ActiveRecord::Base by a file in config/initializers.

Everything works fine and dandy (including mongrel in development  
mode) EXCEPT when I do “reload!” inside script/console – then I get  
the following error the next time any of my ModelSecurity methods are  
called:

ArgumentError: A copy of ModelSecurity has been removed from the  
module tree  
but is still active!

I have tried adding an “unloadable” declaration to my ModelSecurity  
model, but it makes no difference.

I also tried adding the “unloadable” declaration to ActiveRecord::Base  
itself (I was grasping at straws there), but that doesn’t work either  
– it causes “reload!” to fail with:  
NameError: uninitialized constant ActiveRecord::Base

Admittedly this isn’t a huge problem (it only affects script/console)  
but it is annoying because quitting and re-running script/console  
takes ~12s on my system.

Cheers  
Dave.

---

<div class="post-metadata">

**Author:** ![bitsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9de053/32.png) [@bitsmith](https://www.ruby-forum.com/u/bitsmith)\
**Post date:** [September 14, 2008, 5:16am UTC](https://www.ruby-forum.com/t/help-a-copy-of-modelsecurity-has-been-removed-from-the-module-tree-but-is-still-active/148439/2 "2008-09-14T05:16:47Z")

</div>

Hi Dave,

I can’t explain why it happens, but I noticed the same thing while  
debugging a module of my own. After I did the reload!, I needed to  
require the file again. So if my file as custom\_validations.rb, it would  
look like

reload!  
require ‘custom\_validations’

and then it worked.

Peace.

---

<div class="post-metadata">

**Author:** ![bitsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9de053/32.png) [@bitsmith](https://www.ruby-forum.com/u/bitsmith)\
**Post date:** [September 15, 2008, 11:14pm UTC](https://www.ruby-forum.com/t/help-a-copy-of-modelsecurity-has-been-removed-from-the-module-tree-but-is-still-active/148439/3 "2008-09-15T23:14:45Z")

</div>

Cheers for the suggestion, but that didn’t work for me. ☹

On Sep 13, 10:16 pm, Phillip K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![bitsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9de053/32.png) [@bitsmith](https://www.ruby-forum.com/u/bitsmith)\
**Post date:** [September 16, 2008, 5:05pm UTC](https://www.ruby-forum.com/t/help-a-copy-of-modelsecurity-has-been-removed-from-the-module-tree-but-is-still-active/148439/4 "2008-09-16T17:05:51Z")

</div>

On 15 Sep 2008, at 22:12, Dave R. wrote:

> this is on rails 2.1 stable.

Add that file to Dependencies.load\_once\_paths ?

Fred

---

<div class="post-metadata">

**Author:** ![bitsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9de053/32.png) [@bitsmith](https://www.ruby-forum.com/u/bitsmith)\
**Post date:** [September 16, 2008, 3:39pm UTC](https://www.ruby-forum.com/t/help-a-copy-of-modelsecurity-has-been-removed-from-the-module-tree-but-is-still-active/148439/5 "2008-09-16T15:39:14Z")

</div>

For the sake of anyone stumbling on to this from a google search, this  
was answered on the rails-core mailing list:

[http://groups.google.com/group/rubyonrails-core/browse\_thread/thread/710868b1292c737f](http://groups.google.com/group/rubyonrails-core/browse_thread/thread/710868b1292c737f)
