What is the difference between a Ruby Gem plugin and Rails?

As far as I know, the only difference is the "installation". I also heard that plugins are somehow more difficult to update. But did I want to install something as a plugin instead of gem?

+4
source share
3 answers

Gems:

  • Can handle dependencies
  • Can be installed in the system area
  • You can also sell (in vendor/gems )
  • Has a concept of versions, can easily indicate which version you want.

Plugins

  • Very easy to publish for authors.

Apparently, the only advantage for plugins is a strong advantage, since plugins are still very common. I tend to agree. Publishing a plugin = creating a github repository. Publishing a gem requires you to create a gemspeak and possibly even interfere with The Gem Beast (rubyforge), which are both PITAs.

+4
source

I would say that this question is likely to be controversial, and this is the best approach, but my thoughts do not matter.

The biggest victory I would say when using a gem over a plugin, if this parameter is gem dependencies.

Rails plugins do not handle dependencies, so if you install a plugin that relies on other plugins / gems, you have the inconvenience of installing them. Where the installation of a gemstone can at the same time draw in any dependencies necessary for its launch. Take a cucumber pearl, for example:

' sudo gem install cucumber ' will install the cucumber pearl, but also install its dependencies, such as the webrat gem.

This may not seem very important, but when you are dealing with several environments (development, production, production, etc.), you are more likely to encounter dependency problems.

The only scenarios in which you probably want to get a plugin over a gem are convenient access to the plugin code. One case may be if the Infact Rails plugin is an engine, and you need to quickly dive into the code and see which class / view you want to override. Another case could be if you branched out a plugin like active_merchant and configured it as a git submodule in providers / plugins. In this case, fixing and pushing the changes upstream is usually much more convenient.

As for one it’s more difficult to upgrade more, stones have rubigems to manage them, which is fairly straightforward, and if you use git, then modulated plugins are the doddle for updating:

 # installing a plugin as a git submodule git submodule add git://path_to_plugin_git_repo.git vendor/plugins/plugin_name # updating said git submodule cd vendor/plugins/plugin_name git remote update git rebase origin/master cd ../../.. git add . git commit -m "update plugin_name to latest master." 

or equivalent for external SVN

Installing something like a gem or a plugin, however, should not affect the functionality of the code, since they are just two different ways of packing the code, in the end, it comes down to what you consider more convenient to use. Personally, I think that gems are much easier to maintain, unless I get hung up on the code, then I like the submodulated plugin more, because it will appear in the project tree in my editor.

+3
source

I always use gems, if possible, because I feel that they are easier to update.

However , one of the main annoyances is that stones cannot perform rake tasks, but plugins can. This often leads to frustration when, for example, you try to run rake paperclip:refresh only to get information that the task does not exist.

The solution is to copy the rake tasks to the task directory.

+2
source

All Articles