Dave Rothlisberger
2008-Sep-12 19:15 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. 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: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Phillip Koebbe
2008-Sep-14 03:16 UTC
Re: Help: A copy of ModelSecurity has been removed from the
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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dave Rothlisberger
2008-Sep-15 21:13 UTC
Re: Help: A copy of ModelSecurity has been removed from the
Cheers for the suggestion, but that didn''t work for me. :-( On Sep 13, 10:16 pm, Phillip Koebbe <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dave Rothlisberger
2008-Sep-16 13:38 UTC
Re: Help: A copy of ModelSecurity has been removed from the module tree but is still active!
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 On Sep 12, 2:15 pm, Dave Rothlisberger <droth...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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. > > 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: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---