Dave Rothlisberger
2008-Sep-15 21:12 UTC
Help: A copy of ModelSecurity has been removed from the module tree but is still active!
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- security/ ). My ModelSecurity module lives in $RAILS_ROOT/lib. It is automatically included into ActiveRecord::Base by a file in config/initializers. BTW this is on rails 2.1 stable. 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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Sep-15 22:03 UTC
Re: Help: A copy of ModelSecurity has been removed from the module tree but is still active!
On 15 Sep 2008, at 22:12, Dave Rothlisberger wrote:> > 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- > security/ ). > > My ModelSecurity module lives in $RAILS_ROOT/lib. It is automatically > included into ActiveRecord::Base by a file in config/initializers. BTW > this is on rails 2.1 stable. >Add that file to Dependencies.load_once_paths ? Fred> 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. > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Koziarski
2008-Sep-16 09:00 UTC
Re: Help: A copy of ModelSecurity has been removed from the module tree but is still active!
> Hi all, I''m posting this in the hope that someone who understands > rails dependencies can shed some light.Basically the problem is that it''s trying to remove that module, but ActiveRecord::Base still references it. So your module has to live outside of the reloading paths. Either in a plugin or some other path you manually add to load_once_paths (as frederick mentioned). If you want to reload this module you can simulate it with just: load ''model_security.rb'' It''s not strictly the same, but it will have the desired result for you. -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Dave Rothlisberger
2008-Sep-16 13:36 UTC
Re: Help: A copy of ModelSecurity has been removed from the module tree but is still active!
Thanks guys, that worked a treat. It''s nice to understand what''s going on under the hood. :-) Dave. On Sep 16, 4:00 am, "Michael Koziarski" <mich...@koziarski.com> wrote:> > Hi all, I''m posting this in the hope that someone who understands > > rails dependencies can shed some light. > > Basically the problem is that it''s trying to remove that module, but > ActiveRecord::Base still references it. So your module has to live > outside of the reloading paths. Either in a plugin or some other path > you manually add to load_once_paths (as frederick mentioned). > > If you want to reload this module you can simulate it with just: > > load ''model_security.rb'' > > It''s not strictly the same, but it will have the desired result for you. > > -- > Cheers > > Koz--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---