There have been some major changes to Mephisto in the latest release (0.8 Drax) that break existing plugins. If you’re interested in migrating your existing plugin(s) over to Drax, read on.
First thing to note is that the Mephisto code base has moved from SVN to github.
Plugin Architecture Changes
There is no longer a base class for Mephisto plugins. Instead, you create Mephisto plugins using Rails Engines. If you’re migrating a pre-Drax plugin to Drax and Rails engines, you’ll most likely need to:
- Remove your plugin file – there’s no base class for it any more so you’ll get errors like: ‘superclass must be a Class (Module given) (TypeError)’
- Move your routes into a ‘routes.rb’ file in your plugin root directory.
- In your plugin root directory, create an ‘app’ directory, with ‘views’, ‘models’ and ‘controllers’ sub-directories. Move your code files into the appropriate folders in the ‘app’ directory. These will be auto-loaded.
- Remove various lines in your init.rb which manually add your plugin file directories to the load paths, if you have these.
- If you inherit from the ApplicationController, add ‘unloadable‘ to your controller class. This will fix errors in development mode like ‘A copy of ApplicationController has been removed from the module tree but is still active!’
You can have a look at my contact_form plugin code. Revision 18 is before Drax and engines and uses the old approach. Revisions 19 and later are using Rails engines and will work with Drax.
UPDATE: Latest code at GitHub