This project is archived and is in readonly mode.

#1999 ✓stale
Björn Grossmann

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

Reported by Björn Grossmann | February 17th, 2009 @ 04:26 PM | in 3.x

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!

Comments and changes to this ticket

  • Adam McCrea

    Adam McCrea April 2nd, 2009 @ 06:16 PM

    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.

  • Adam McCrea

    Adam McCrea April 2nd, 2009 @ 06:17 PM

    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.

  • James Adam

    James Adam April 3rd, 2009 @ 04:36 PM

    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?

  • Dan Croak

    Dan Croak April 23rd, 2009 @ 03:54 AM

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

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

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

  • Jeremy Kemper

    Jeremy Kemper May 4th, 2010 @ 06:48 PM

    • Milestone changed from 2.x to 3.x
  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:54 PM

    • 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.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:54 PM

    • State changed from “open” to “stale”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages