Archive for March 2010

rails3 engine as gem vs plugin

I’m trying to update a 2.3.5 engine to work with 3, and am in somewhere in the steep logarithmic climb of the learning curve. Fortunately @josevalim has a gem out called enginex that sets things up quickly. I was attempting to set up a new engine project with tests, and doing it manually was going absolutely nowhere.

Note: It’s a bit frustrating that I can’t tell the difference between my personal attempts and the output of enginex, and why the one works but the other didn’t. At least I have something that works now, though.

I just ran into something interesting, which is that my engine in the plugins directory gives an error, “‘my_engine’ is a Railtie/Engine and cannot be installed as plugin”. I see no documentation indicating what is the preferred way to load engines, so I’m skipping the entire thing and turning my engine into a gem.

Perhaps this is the preferred way of managing engines?

Unclear. Again, what it comes down to is that the gem works. I guess this is the pain of riding the edge, with such a tremendous change in the framework.

UPDATE: This gist explains, among other things, why the way I was setting up my engine was not working as a plugin: Rails automatically reads plugins as engines, so when I was specifying an Engine class it was getting loading the engine twice.