Chronicling my experiences with ruby on rails, web application development/management.

Saturday, December 20, 2008

Solved: ApplicationController has been removed from the module tree error.

A copy of ApplicationController has been removed from the module tree but is still active!
You got this error... and now you don't know what to do. Well i can offer a suggestion or two on how to fix it.

Symptoms


You may be trying to update a plugin that is conflicting with ApplicationController. You'll also notice that this error happens when you try to reload the same page, or even move a different view within the same directory. For instance, if you load plugin/index and the try to reload OR go to another link say plugin/new, you get this error.


Hit me nerbie69! Solve my problems


Well dude, you got way too many for me to solve, but this one is on me.


All douchery aside, i solved my error by deleting some of the leftover cruft of having a generator plugin, that i converted into a engines based plugin. github nerbie69/railstat plugin check out the forked project for the current generator based script.


#OLD code
require_dependency 'path_tracker'

class RailStatController < ApplicationController
include PathTracker

before_filter :extract_subdomain
....


#new code notice the difference
class RailStatController < ApplicationController
unloadable
include PathTracker

before_filter :extract_subdomain
...



Since ApplicationController is an unloadable class, we too had to match it's unloadability in our app/controllers directory of our engines based plugin. Also, we don't need the require statement, as you do when you are using a generator plugin, if you are referencing the lib directory. The engines takes care of that for you too.


Wrap it up Johnny!


Ok, engines rock. Also, you can apply this code to any of these stupid errors you might get in the future for other controllers and plugins.


Sources: rails trac from 2006.

2 comments: