views:

30

answers:

2

I think I understand it as, if it is Rails 2.x

config.gem 'gem_name'   # in config/environment.rb, and then rake gems:install

and in Rails 3.x

gem 'gem_name'          # in Gemfile, and then bundle install

these are the two standard ways to add a gem into a Rails project.

Is there a standard way to add a plugin? It seems that it usually get installed as

script/plugin install _________________.git

and what is the standard way to include it?

(I think the current recommendation is to use gem or bundler, but what if we just need to use plugin in a particular situation?)

+2  A: 

After running script/plugin install, the plugin ends up in vendor/plugins, the contents of which are included automatically on startup. If that folder is checked into version control, you're good to go.

Matchu
so Rails 2.x and 3.x both will automatically load anything inside of `vendor/plugins`... and it is not true for anything in `vendor/gems`... anybody knows which part of Rails code does that?
動靜能量
@動靜能量: That's right :) Not sure where the plugin loader code is. Why do you ask?
Matchu
@動靜能量: Got a bit closer. [railties/lib/rails/application.rb](http://github.com/rails/rails/blob/3022ce4f723075d201d9a20f7bca3537aa76a7d8/railties/lib/rails/application.rb#L85) loads the initializers from `Plugin.all` into the application initializers. [Plugin.all](http://github.com/rails/rails/blob/master/railties/lib/rails/plugin.rb#L29) loads those plugins straight from the `vendor/plugins` directory listing.
Matchu
+1  A: 

In Rails 3.x you need to install plugins with rails plugin install

Alternative way is to clone git repo into plugins directory:

cd vendor/plugins/    
git clone http://github.com/__plug_name.git

or add as submodule to application:

git submodule add http://github.com/__plug_name.git vendor/plugins/__plug_name
NARKOZ