问题
On http://github.com/collectiveidea/delayed_job
it says:
To install as a gem, add the following to config/environment.rb:
config.gem 'delayed_job'
Runrake gems:install
versus
To install as a plugin:
script/plugin install git://github.com/collectiveidea/delayed_job.git
What is the difference between installing it as a gem or as a plugin?
Also, the first method just install gem 2.0.3 which might be the tobi's version? (rake gems:install
installs the version by gem list -r delayed_job
) Is it http://github.com/tobi/delayed_job ?
The "plugin" method specifically says it is the collectiveidea version? Doesn't it matter which one you install?
回答1:
Both the Gem and the vendored plugin refers to the collectiveidea's fork. In fact, collectiveidea is the current maintainer for the delayed_job
Gem on RubyGems.
That said, generally speaking installing a plugins as a Gem has many advantages.
- You can install it once and use it in many different projects
- You can take advantage of dependency resolution
- You can upgrade just changing version number
- You don't need to store the entire plugin code in your SCM
So, why you can install a plugin "as a plugin"? There are many different answers.
At the very beginning, Rails plugins came as simple libraries. Time passes and developers started to notice the advantage of packaging plugins as Gem.
Also, before Rails 3, some plugin features were only reserved to plugins and not to Gems. For instance, before Rails 3, plugins could bundle rake tasks while there wasn't a way to inject new rake tasks or new routes into the main application.
In the last two years, the most part of Rails plugins offers the ability to be installed as a plugin or as a Gem. With Rails 3 and the arrival of Bundler, I'm sure plugins are going to be deprecated in favor of Gems.
回答2:
That are 2 different repositorys, maybe you shoult try
config.gem 'delayed_job', :source => http://github.com/collectiveidea/delayed_job.git
Look at: http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies
Btw. maybe you want to look at a maybe better solution: resque - see http://ruby-toolbox.com/categories/queueing.html for a comparison of used queing gems
回答3:
When you install a gem it will be available for all apps, in case you use a plugin - just for an app it's installed into.
回答4:
The basic difference is a gem is something that gets installed on the system running your Rails application, whereas a plugin is installed along with your application, plugin does not get installed on the system level.
suppose you are using rvm and let us take this example.
we have two applications app1 and app2
both are running on a common rvm gemset named gemset1
when you add a gem in the gemfile of app1 and run bundle install and then being in the same rvm gemset which is gemset1, if you run the second app app2 the gem will be available in the second application as well
Whereas with the plugin it will not be the case because plugins get installed on application level and not at the system level
来源:https://stackoverflow.com/questions/3629919/in-ruby-on-rails-whats-the-difference-between-installing-something-as-a-gem-or