Migrating Mephisto Plugins to Drax 0.8

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.

Repository Move
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!'
  • An example
    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
    http://github.com/jcrisp/mephisto_contact_form/tree/master


Actions

Information

3 responses to “Migrating Mephisto Plugins to Drax 0.8”

25 08 2008
James Crisp - C#, JRuby, Ruby on Rails, .NET, book reviews, film reviews, mind hacks, Wing Chun and the occasional personal bit. » Contact Form For Mephisto updated for Drax 0.8 (15:30:45) :

[...] you’re a Mephisto plug-in developer, you might be interested in checking out my post on migrating Mephisto plugins to Drax. It’s based on my experiences with the [...]

25 08 2008
26 08 2008
Nome do Jogo » Blog Archive » Rails Podcast Brasil - Episódio 29 (15:39:18) :

[...] Migrating Mephisto Plugins to Drax 0.8 [...]