27.02.2013 Views

Rails%203%20In%20Action

Rails%203%20In%20Action

Rails%203%20In%20Action

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

This chapter covers<br />

� The importance of engines for Rails 3<br />

� Building a new engine and exploring the base<br />

� Using behavior-driven development to develop an engine<br />

� Releasing the engine as a gem<br />

� Integrating an engine with an app<br />

468<br />

Engines<br />

Engines are a new feature for Rails 3. 1 They are effectively miniature applications<br />

that provide additional functionality to an application, and they function in much<br />

the same way as an application.<br />

Back in chapter 6, you used the Devise gem, which itself is an engine. Other<br />

engines include the RailsAdmin 2 and forem 3 engines.<br />

An engine allows you to share common functionality across applications in the<br />

form of a gem or a plugin. 4 This functionality could be an authentication system such<br />

1 Although in previous versions they were supported by a plugin written by the community: https://<br />

github.com/lazyatom/engines.<br />

2 http://github.com/sferik/rails_admin.<br />

3 http://github.com/radar/forem.<br />

4 In Rails 3, these two are basically interchangeable. One lives in vendor/plugins, the other is installed<br />

using gem. For all intents and purposes, they work in a near-identical manner. Developers should try to use<br />

gems where possible, as they are versioned and easy to upgrade to specific versions, where plugins are not.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!