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

Showing posts with label engines. Show all posts
Showing posts with label engines. Show all posts

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.

Tuesday, December 16, 2008

Rails Engines are awesome!!!!

Some of my loyal fans may be shocked to know that i just tried the Rails Engines plugin. Officially titled engines plugin on github.


So easy, and exactly as advertised


Sometimes, try as we may, things aren't always as advertised in this community of ours. So it is a good when things go exactly as planned


Instructions on using the plugin are well written in the README, so i won't bore you with those details, but if you have ever wanted to make a plugin that had the same familiar structure as your rails app', then this is for you. All you need to do is create a plugin and then add the same app directory structure in the root folder of the plugin.


Predictions


Theoretically you can make all of your controller, models and views as plugins, making your app act almost like it's own SAAS appliance. If you have a generator style'd plugin, there is no reason not to use engines. Less coding for you, the plugin creator.


Examples of Hot Rails Engines Action (HREA?)


In fact, i just put the finishing touches on my fork of the rails stat plugin, that was purely a generator script, basically. Now in my forked version, the engines plugin takes care of generating static code within an app. And that is pretty frickin cool.