Email the Author
You can use this page to email Luís Ferreira about Start Your Engines.
About the Book
Ruby on Rails is one of the most used frameworks for web development and it is used even more by companies providing SaaS. In my opinion SaaS should be all about modularity, and that's where Rails Engines come in. So, if you're doing SaaS, want to create RoR Engines or just want to learn one of the coolest things in RoR, this book is for you! ;)
It will focus mainly on:
- How to create an engine
- Best practices for developing an engine
- A bit of metaprogramming (one of the most essential parts of building engines, IMO)
- Testing
- Deploying (i.e, merging with an actual app)
This is obviously subject to major refactoring until the book is published.
Here's the intro so you can have a little taste. Enjoy.
A little bit of History
Rails applications have evolved a whole lot throughout the years so, before even talking about engines let's take a step back and look at that nasty beast that were plugins.
Plugins and Engines are very much alike in terms of the problem then intend to solve, that is when you want to experiment on new stuff without hurting the stable code base or just modularize your code so that it is more easily tested, maintained and reused. They do, however, have some differences in how they approach this problem.
Prior to rails 3 plugins would live in the vendor/plugin directory and they would work fine if what you wanted was to extend ActiveRecord or String or any other class. On the other hand if you wanted like to add an actual model, controller, asset or even migration, brace yourself, your were in for a real treat.
Adding a controller would involve creating a generator that would copy it to the correct folder in the app, and the same goes for assets and migrations. This not only was a tedious job as it defeats one of the reasons we were using plugins in the first place, since it merges the plugin code with the application code. What a mess!*
As you might imagine these are just some of the more obvious problems with rails 2 plugins and quite frankly I think this is why nobody really used them.
When rails 3 came out the concept of engines came with it, these were plugins but were bundled in a gem. They were not quite as spectacular as they are today and I will not give them too much attention, I just want to mention a gem that was written by José Valim, a core Rails contributor, called Enginex. What this gem does is scaffold an engine with all the structure you need, as well as some very helpful boilerplate code.
At the time rails 3.1 was released, Enginex was bundled together with it bringing some other nice tweaks. This was the dawn of the age of the Engines!
*Some of them were actually more inteligent than this, but with practically no support from rails itself, it was a hard task.
About the Author