In rails I have to install as a gem or plugin

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

What is the advantage of one over the other. Later I plan to place this application on a client server for permanent hosting. so am I better off having it like a gem? if it’s like a gem ... when I put the application on the client server ... I don’t have to get this plugin again?

+4
source share
3 answers

In general, gems are a more reliable and supported way to add functionality to your application. There is a whole infrastructure on the Internet and is built into Rails for working with precious stones, which are not for plugins.

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

Run at the root of your project ...

$ 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. This gives you the ability to automatically install them using ...

 $ rake gems install 

Another advantage of gems over plugins is that at the system level you have a gem utility for saving gems, which makes the task easier.

if it’s like a gem ... when I put the application on the client server. I will not need to download this plugin again?

You can freeze gems in your application and deploy them as part of the application without installing them in the system. If you do this, you won’t have to get this stone or plugin again unless you want to upgrade to a newer version.

+1
source

As I understand it, they behave very differently:

  • The plugin is only available for the application in which you are located. Therefore, if you want to freeze it in your application and want to simplify delivery, use the plugin.
  • gemstone set for the entire ruby ​​setting. Therefore, it is better to share the gem between applications. However, you should keep in mind that upon delivery you need to additionally install the gem on the client machine.

So, in your case, I would prefer to use a plugin rather than a gem.

0
source

It may be easier for you to debug a plugin against a gem. It is also nice if in your IDE you need to find the code that is in your application tree.

I am pleased to install plugins for development and transition to gems after the release of the code.

0
source

Source: https://habr.com/ru/post/1304426/


All Articles