Gem Vs Plugin Vs Engine in Ruby on Rails

Gem Vs Plugin Vs Engine In Ruby On Rails

Gem Vs Plugin Vs Engine in Ruby on Rails

Plugins as you knew them from Rails 2 (i.e. plugins beneath the vendor/plugins folder) have been deprecated for Rails 3.2; assist for it was fully eliminated in Rails 4. Now, theres an idea of a gemified plugin the place the plugins are primarily constructed as gems, and will be shared throughout totally different Rails functions.

But to reply your query about gems vs plugins, take a look at this Stackoverflow answer. Long story brief, plugins from the Rails 2 universe is an extension of the rails software, whereas a gem is a packaged ruby software.

As for Rails engines, Ive discovered this to be a pretty easy and intuitive definition of a Rails engine:

Rails Engines is mainly a complete Rails app that lives in the container of one other one. Put one other manner, because the docs be aware: an app itself is mainly simply an engine on the root stage. Over the years, we’ve seen sen engines as components of gems equivalent to devise or rails_admin. These instance present the facility of engines by offering a big set of comparatively self-contained performance “mounted” into an app.

And since each rails engines and plugins are varieties of ruby functions, they will all technically be packaged and used as a gem (normally).

There are not any extra plugins since Rails 4. Rails 4.0 release notes:

Rails::Plugin has gone. Instead of including plugins to vendor/plugins
use gems or bundler with path or git dependencies.

Any engine will be contained in a gem. Gem is simply an alias to a library.

READ :  Python Solving – ModuleNotFoundError: No Module Named ‘tensorflow’

Best technique to see what their distinction is, is producing three of them and searching by their listing construction:

bundle gem a_gem, use for non-rails-specific performance.

rails plugin new b_railtie, use for rails extensions that dont require full application-like setup. however, since its nonetheless a rails-specific setup (you get your Rails dummy app in /take a look at eg), you’re most likely going to make use of railtie in it. railtie is a category that inherits from Rails::Railtie, and offers you the comfy DSL to hook up your code into Rails. eg, in order for you some motion carried out :earlier than some Rails app initialization step, you should use initializer Railtie class_method. Paperclip

rails plugin new c_engine --full, use for rails extensions that can be full-fledged app themselves, mounted into your app. offers you /app dir and Engine subclass apart from fundamental non---full setup.

rails plugin new c_engine --mountable, similar as --full, however will create namespaces, able to be mounted into your app engine. Spree

And here’s a fairly good hyperlink:

Gem Vs Plugin Vs Engine in Ruby on Rails

Answer quoted from Difference between plugins and Ruby gems?


  • Gem is a packaged ruby software utilizing the packaging system outlined by RubyGems.
  • Rails itself is a Gem.

    Rails gem is put in in jruby-1.0librubygems1.8gemsrails-1.2.3 as:

    DIR bin
    DIR builtin
    68,465 CHANGELOG
    DIR configs
    DIR dispatches
    DIR doc
    DIR environments
    307 fresh_rakefile
    DIR helpers
    DIR html
    DIR lib
    1,072 MIT-LICENSE
    11,969 Rakefile
    8,001 README
    The lib listing accommodates all of the gem supply code.

  • We can set up,improve and question the gem model.If one makes use of a software like my GemInstaller, one can simply automate the set up and loading of RubyGems with a single easy config file.
  • Gem put in for Ruby interpreter can be utilized system-wide by that interpreter.
  • Gem could also be revealed as a plugin.
  • Can even be vendored in vendor/gems.


  • Plugin is an extension of Rails Framework.
  • Can not be upgraded through the use of a command. To improve one need to uninstall after which set up upgraded model.
  • Has to be hooked into rails software. (has to have init.rb)
  • Have an set up.rb file.
  • Plugin can’t be revealed as a Gem.
  • Can solely be used software extensive.

Goldspike plugin is put in in vendorpluginsrails-integration listing of the applying as:
7,089 construct.xml
1,141 LICENSE.txt
DIR plugins
6,675 pom.xml
1,447 README
DIR samples
plugins/goldspike listing consists of
24 init.rb
25 set up.rb
DIR lib
549 Rakefile
DIR duties
DIR take a look at
The lib listing accommodates all of the plugin supply code.

Gem vs Plugins

  • Rails had a manner of loading plugins from the seller/plugins/ listing. This will almost definitely deprecate as Rails has added assist for bundling gems with the undertaking
    in the seller/gems/ listing.
    The gem variations of rspec are those which can be meant for on a regular basis use. One ought to go together with these until you’re supporting a Rails software in the 1.2.x household or earlier.
  • It typically turns into faster to check-in and check-out of a repository utilizing Gems as you aren’t together with the library in your precise software.
    There are sometimes lesser issues utilizing Plugins associated to incompatibility arising regarding software program variations among the many distributed workforce.
  • General rule of thumb is to make Rails-specific performance a plugin whereas making extra normal Ruby libraries into gems.
READ :  How to Solve Python ModuleNotFoundError: no module named ‘webencodings’


An Engine in rails terminology is a really a subapplication of a web-application. For occasion, one thing like a weblog, a discussion board, or easy authentication: these should not full-blown functions, however pages/views/controllers/fashions that may be added to any rails software.

In rails2 this could be carried out utilizing a plugin. Now since rails3 an engine will be packaged in a gem.

  • A gem: is a generic library, which will be simply put in, that are version-managed, have dependencies and such.
  • An engine: is a sub-application of a Rails software, and since Rails 3 these are distributed as a gem (which is superior!).

So when will you employ one or the opposite:

  • create a gem if you wish to share ruby-functionality
  • create an engine (and package deal it in a gem) you probably have components of your rails software that can be utilized extra typically.

Here is an archived tutorial for creating an engine..

Related posts on Ruby on Rails :

Leave a Reply

Your email address will not be published.