Create a plugin or gem?

Usually I create a plugin when I have a module that, as I know, I will need again in my other projects, however they can also be packaged as gems.

When should I build a gem over creating a plugin? Are there any criteria for making a call?

+6
plugins ruby-on-rails gem
source share
3 answers

Plugins are now becoming obsolete since you can manage gems through the config.gem statement in environment.rb. Gems are available in a system-wide mode (not only in one application), and versions other than plug-ins.

I recently converted all my plugins to gems. Easy to do and worth it.

+9
source share

The rails seem to be moving toward the direction of the gems. Now I have converted most of my plugins into gems. Gems are easier to manage and better suited to the Ruby ecosystem. Why do we need two different systems?

However, a problem with gems: it is not possible to add rake tasks to a Rails gem application. Probably the same applies to generators, although I'm not sure. If you use them in your plugin, switching to a gem is still not possible. Hope it fixes soon.

+1
source share

You can add generators to rails through gems. it's actually pretty easy, you can just add the rails_generators directory to your gem. (I think other directory names will work - I'm not sure I'm looking for rails). Example: http://github.com/remi/rackbox/tree/a21c21667c68d5fd51357e28f0742171e9161e9b/rails_generators

how to add rake tasks ... I have yet to figure out how to do this: /

while I have my generators, add require 'myproject/rails/tasks' (or something) to your Rakefile project as a way to add rake tasks to gem rails.

many gems ask you to “load” them into your rails project, for example. sudo gem install cucumber cd rails_app. / script / generate cucumber # bootstrap cucumber in your application

+1
source share

All Articles