home projects sketches open source talks

Rails plugins and routes

19 August 2009

While extracting some code I wrote for sanbit to put into a rails plugin, I ran into a few problems getting the routes to work. I finally figured it out after wasting a couple of hours debugging. The rails docs say that if you have a plugin with a routes.rb in “vendor/plugins/yourplugin/config/”, then it will automatically load up your routes file. That is partially true. For that to work you must also have an apps directory inside of your plugin root. It doesn’t matter if the directory is empty, it just needs to be there. This seems to me like a case of too much magic in rails and not enough documentation. Well, hope this can save other people some time.