Tutorial :in rails should i be installing as a gem or a plugin


I am trying to use acts_as_audited plugin. Should I be installing it as a gem (put it in environment.rb) or a plugin?

what is the advantage of one over the other. Later on I plan to put this app on the clients server for permanent hosting. so am I better off having it as a gem? if it is as a gem ...when i put the app on the clients server..will I not have to get this plugin again?


In general gems are a more robust and supported way to add functionality to your app. There's a whole infrastructure on the Web and built into Rails to work with gems that isn't there for plugins.

For example, if you use a gem you get the whole set of Rake tasks for dealing with gems.

In your project root, run...

$ rake -T gem    (in /Users/username/project/someproject)  rake gems                      # List the gems that this rails application depends on  rake gems:build                # Build any native extensions for unpacked gems  rake gems:build:force          # Force the build of all gems  rake gems:install              # Installs all required gems.  rake gems:refresh_specs        # Regenerate gem specifications in correct format.  rake gems:unpack               # Unpacks all required gems into vendor/gems.  rake gems:unpack:dependencies  # Unpacks all required gems and their dependencies into vendor/gems.  rake rails:freeze:gems         # Lock this application to the current gems (by unpacking them into vendor/rails)  

You can also specify gem dependencies in your environment.rb file. That gives you the ability to automatically install them with...

$ rake gems install  

Another advantage of gems over plugins is that on the system level you have the gem utility for maintaining gems so that makes things easier.

if it is as a gem ...when i put the app on the clients server..will I not have to get this plugin again?

You can "freeze" gems into your app and deploy them as part of the app without installing them on the system. If you do that you won't have to get the gem or the plugin again unless you want to upgrade it to a newer version.


As I understand it, the two behave quite different:

  • the plugin is only available for the application you are in. So if you would like to freeze it in your application, and want to simplify the delivery, use the plugin.
  • the gem is installed for the whole ruby installation. So it is better to share a gem between applications. However, you have to keep in mind that on delivery, you have to additionally install the gem on the client machine.

So in your case, I would prefer to use the plugin, not the gem.


You may find it easier to debug a plugin vs. a gem. It's also nice if in your IDE you need to search for code that's within your app tree.

I find it's nice to install plugins for development and the transition to gems after the code is released.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »