Monday, February 22, 2010

Rails plugins and gems

In each rails project, there is a folder named gems and plugins. They are lib files needed for the project. You can install a gem or a plugin into plugins folder. For example, if you want to install will-paginate, you can run the following in the command prompt windows. Then, your rails will recognize the gem:
$ gem install will_paginate
Successfully installed will_paginate-2.3.12
1 gem installed
Installing ri documentation for will_paginate-2.3.12...
Installing RDoc documentation for will_paginate-2.3.12...


However, when you share this lib of the project with others, others need to install the gem. But, if you put the lib into your project, others do not need to install the gem. Therefore, since rails 2.1, you can put the lib into the plugins folder with the follwing command:
$ ./script/plugin install git://github.com/mislav/will_paginate.git

Then, you can find the lib folder as follows: your_project/Vendor/plugins/will_paginate

No comments:

Post a Comment