Engines, Plugins, Gems and Components

Is there a complete document out there that describes the differences,
preferences, and logic between each of the Ruby/Rails extension modules?

Why/when would I use one over the other? and what’s the reasoning behind
having so many choices? I want to write some modular Rails code, both
to submit, and for in house libraries, but with all the choices, I don’t
which way to go.

Thanks
Matt

If you code only makes sense in terms of a Rails application, or
overrides/enhances some features of Rails, you’re probably better
creating a plugin (or a plugin ‘stub’ that loads a gem, if you’re
feeling fancy). Because plugins are ‘simpler’ than Gems, they can be
included into an app easily (svn externals are particularly useful) and
so there’s a little bit less to worry about with deployment.

Instead of svn:externals, take a look at using Piston to manage your
plugins: http://www.rubyinside.com/advent2006/12-piston.html


Rick O.
http://weblog.techno-weenie.net
http://mephistoblog.com

On 1/13/07, matt [email protected] wrote:

Matt
Gems are ruby libraries:
http://rubygems.org/

Rails Plugins provide a way to modify the rails framework or add new
features to it:
http://nubyonrails.com/articles/2006/05/04/the-complete-guide-to-rails-plugins-part-i

Engines are rails plugins that tack on other neato features:
http://rails-engines.org/

Components never really caught on, plugins/engines replaced any desire
for them.


Rick O.
http://weblog.techno-weenie.net
http://mephistoblog.com

James,

Thanks for the insight! I really didn’t mean for you to write an
article on the spot, but it is much appreciated. I’ve been trying to
capture some of these responses, so that the group as a whole can
redirect questions to specific answers, and minimize the extra traffic
on the mailing list.

Thanks again James

Matt

matt wrote:

So I take it that there isn’t a document/article that
compares/contrasts?
pros/cons?
when to use/not to use ?
rationale of using one over the other?

Presumably you’re talking about when to write one type of reusable
library as opposed to another? There are no clear-cut “pros/cons” to
either since their appropriateness depends on what exactly you’re
trying to share. However:

If you’re writing a Ruby library that could be used for projects beyond
Rails, make a Gem; it’s the de-facto standard for distributing Ruby
libs. Gems have nice features like being able to load a specific
version, and automatically installing dependencies, but are most
typically installed as part a system’s global Ruby library set, rather
than being associated with a particular application. If you go this
route when writing enhancements for Rails apps, it can add another
hop-skip-step to your deployment (i.e. ensuring that all the
appropriate gems are either installed or unpacked into your app for
each target machine).

If you code only makes sense in terms of a Rails application, or
overrides/enhances some features of Rails, you’re probably better
creating a plugin (or a plugin ‘stub’ that loads a gem, if you’re
feeling fancy). Because plugins are ‘simpler’ than Gems, they can be
included into an app easily (svn externals are particularly useful) and
so there’s a little bit less to worry about with deployment.

If you want to share Rails-specific things like controllers, routes,
migrations and such, write a plugin and request that users install the
engines plugin along side it, since it makes sharing such things quite
easy when appropriate.

HTH

James

So I take it that there isn’t a document/article that
compares/contrasts?
pros/cons?
when to use/not to use ?
rationale of using one over the other?

Matt

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs