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
Related posts:- Ruby-on-Rails Hello World on GlassFish
- TOTD #14: How to generate JRuby-on-Rails Controller on Windows (#9893)
- Rails and Java EE integration – Servlet co-bundled and invoked from Rails
- TOTD #24: Getting Started with Rails 2.0.x in JRuby 1.0.3 and JRuby 1.1RC1
- TOTD #13: Setup Mongrel for JRuby-on-Rails applications on Windows
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
Comment by Klaus Ramelow — September 10, 2007 @ 8:11 am
I can view the information fine on 1024 x 768 resolution. What is your resolution ?
Comment by Arun Gupta — September 12, 2007 @ 6:43 am
great! thanks a lot for this, I’m a Rails and Ruby n00b and this was very helpful
Comment by ryouji_shiki — November 7, 2007 @ 9:34 am
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
Comment by Chad Woolley — December 8, 2007 @ 1:14 pm
Chad, thanks for the additional tip!
Comment by Arun Gupta — December 13, 2007 @ 11:38 pm
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?)
Comment by Joel Nylund — February 28, 2008 @ 2:02 pm
@Klaus: see the Matrix via the Firefox menu View -> Page Style -> No Style.
Comment by Matt Platte — June 14, 2008 @ 9:46 am
dffsfdfsf
Comment by sfafsaf — November 3, 2008 @ 9:51 pm
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?
Comment by BATTERY — November 27, 2008 @ 5:18 pm
thanks for putting it up
Comment by anon — May 7, 2009 @ 12:49 pm
Thanks for posting this. Though I haven’t created gems or plugins, I’ve often wondered how they work – especially how plugins initialize (with init.rb).
Comment by Michael McCracken — April 16, 2010 @ 2:18 pm