Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Rails 2.3 RC1 engine problem with load-order when used with restful_authentication and role_requirement

#1999

I set up a rails app with restful_authentication and role_requirement.

I create a simple engine ("plugin") with an app-directory and a controller with one action and a view for this action.

In the view, I access the "current_user" method of restful_authentication.

The first time this loads fine (in most cases). When I reload the page in my browser, I get this error:

"A copy of AuthenticatedSystem has been removed from the module tree but is still active!"

Now comes the strange thing: When I move the controller from vendor/plugins/welcome/app/controllers/ over to my regular app/controllers/ directory, everything works fine (even for reloads)!

I have attached a template, so you can create a rails app using rails testapp -m /path/to/rails-template.rb

Thanks for the great work you are doing!

Reported by Björn Grossmann · February 17th, 2009 @ 04:26 PM

State: stale
Milestone: 3.x
Assigned to: nobody
Importance: none

Activity

  1. Adam McCrea
    Adam McCrea

    I just got bit by this as well. In my case I had a controller inside my engine plugin that subclassed ApplicationController (as most controllers do). This forces ApplicationController - and any modules it includes - to be loaded with the plugin on the first request.

    The problem comes on the next request when (in development) Rails tries to unload most constants in the application, including ApplicationController and the modules it included (if they were in /lib). Since plugins don't get reloaded between requests, though, my plugin was trying to hold on to these constants, producing the "removed from the module tree but is still active" error message.

    I fixed the problem by adding this to the init.rb for my plugin:

    
    ActiveSupport::Dependencies.load_once_paths.delete(
      File.expand_path(File.dirname(__FILE__))+'/app/controllers')
    

    The scenario and how it all works is explained better here.

    April 2nd, 2009 @ 06:16 PM

  2. Adam McCrea
    Adam McCrea

    I should also add that I'm not sure this is something that needs "fixed" in Rails, but it could certainly use some documentation. I'm not even sure if what I did is a good way to fix the problem, or if I'm trying to do something I shouldn't.

    April 2nd, 2009 @ 06:17 PM

  3. James Adam
    James Adam

    I can't replicate this using your template. I generate the application, start script/server (in development mode), and then hit http://localhost:3000/welcome as many times as I can.

    Should I try to log in using the restful_auth you've installed?

    April 3rd, 2009 @ 04:36 PM

  4. Dan Croak
    Dan Croak

    We get around this problem in Clearance by using the unloadable method:

    http://github.com/thoughtbot/cle...

    http://apidock.com/rails/ActiveS...

    April 23rd, 2009 @ 03:54 AM

  5. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  6. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open
    • Tag changed from 2.3-rc1, engines, load-order, restful_authentication, role_requirement to 23-rc1, engines, load-order, restful_authentication, role_requirement
    • Importance changed from to

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:54 PM

  7. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:54 PM