Tuesday September 04, 2007
TOTD #6: Difference between Ruby Gem and Rails Plugin
As a newbie to Rails, "Gem" and "Plugin" terminology was slightly confusing to me. Specifically I saw the terms being used interchangeably sometimes. This TOTD highlights the difference between Ruby Gem and Rails Plugin.
Ruby Gem and Plugin are both packaging systems - the main difference is the scope in which they are effective. The common differences are highlighted in the table below.
| Topic | Ruby Gem | Rails Plugin |
| Definition | A Gem is a packaged Ruby application using the packaging system defined by RubyGems. | A Rails plugin is a packaged Ruby application that extends the core Rails framework. |
| Example | Has a name (e.g. rake) and a version (e.g. 0.4.16). Rails is also installed as a Gem. | Has a name (e.g. Goldspike) and a version (e.g. 1.1.1). |
| Scope | Installed in the Ruby or JRuby installation and is available to all applications run using that interpreter. | Installed in a specific Rails app only. |
| Packaging System | Rails gem is installed in
jruby-1.0\lib\ruby\gems\1.8\gems\rails-1.2.3 as:
The |
Goldspike plugin is installed in
vendor\plugins\rails-integration directory of the application as:
The |
| Management | Gems are managed on your computer using the gem command. You can install, remove and query gem
packages using the gem command. |
Plugins can be installed using after creating a Rails application and then
invoking the command |
| Load Path | gem command adds the lib
directory of your gem to the load path of Ruby. |
Rails adds the lib directory of plugin in
your application's load path. |
| Specific Features |
|
|
| Publish Format | A Gem may be published as Plugin, for example ActiveRecord-JDBC. | A Plugin cannot be published as Gem. |
Here are some useful entries (with numerous pointers on screencasts, blogs, tips & extensive feature sets) to get you started with JRuby:
Are there any other main differences that I missed ?
Please leave suggestions on other TOTD that you'd like to see. A complete archive is available here.
Technorati: totd rubyonrails rubygem railsplugin netbeans glassfish
Posted by Arun Gupta in web2.0 | Comments[10]
|
|
|
|
|
Today's Page Hits: 921
Total # blog entries: 1009
I am interested in your showing of
Ruby Gem and Rails Plugin
but sorry, I am unable to read the information
on this site because the calender is shown as
background and other information as overlay of
the Rails Plugin information.
It seems this page is not prgrammed true to
conventions.
My browser Firefox 2.006.
Klaus Ramelow
Posted by Klaus Ramelow on September 10, 2007 at 08:11 AM PDT #
I can view the information fine on 1024 x 768 resolution. What is your resolution ?
Posted by Arun Gupta on September 12, 2007 at 06:43 AM PDT #
great! thanks a lot for this, I'm a Rails and Ruby n00b and this was very helpful
Posted by ryouji_shiki on November 07, 2007 at 09:34 AM PST #
Great writeup.
I would make a correction, though. Plugins MAY have a version. Many don't - all they have it a subversion repo.
This is one of the main benefits of gems vs. plugins, in my opinion. Gems MUST have a version, which means it is always possible to ensure that you are running a specific version (using the RubyGems 'gem' method to put a specific gem version on your load path). You can also use advanced versioning to automatically use a more recent version, if available, or to do fancy things such as using a newer "TINY" or "MINOR" version, but not a newer "MAJOR" version.
With a plugin, you are dependent on the developer to provide SVN tags to indicate individual versions - but they don't necessarily have to (and often don't, because they don't have to make a new version in order to release, like they do with gems). You also have to manually install the new versions, instead of using flexible versioning to automatically pick up newer versions.
Also, if you use a tool like my GemInstaller (http://geminstaller.rubyforge.org), you can easily automate the installation and loading of RubyGems with a single simple config file.
-- Chad
Posted by Chad Woolley on December 08, 2007 at 01:14 PM PST #
Chad, thanks for the additional tip!
Posted by Arun Gupta on December 13, 2007 at 11:38 PM PST #
Hi, this is very helpful, some more that would be good is how do you access gems vs plugins within rails, are they the same, do you need to do a 'require' for one and not the other. Also if a package has a gem and a plugin distribution, and you install both of them, who will win? (which will be used by rails?)
Posted by Joel Nylund on February 28, 2008 at 02:02 PM PST #
@Klaus: see the Matrix via the Firefox menu View -> Page Style -> No Style.
Posted by Matt Platte on June 14, 2008 at 09:46 AM PDT #
dffsfdfsf
Posted by sfafsaf on November 03, 2008 at 09:51 PM PST #
you access gems vs plugins within rails, are they the same, do you need to do a 'require' for one and not the other. Also if a package has a gem and a plugin distribution, and you install both of them, who will win?
Posted by BATTERY on November 27, 2008 at 05:18 PM PST #
thanks for putting it up
Posted by anon on May 07, 2009 at 12:49 PM PDT #