Chapter 14. Extending Rails with Plug-ins
Eventually, you’ll want to extend Rails by installing third-party software to accomplish tasks that the Rails framework is not designed to handle. There are several ways to do this. The most common facilities for extending Rails are RubyGems and Rails plug-ins.
The RubyGems package management system is not Rails-specific, but
rather a standardized system for managing and distributing Ruby
packages, or gems. Many gems are designed specifically for use with
Rails. To use a gem in a Rails application, you have to add an
require directive somewhere in the
application. Typically, gems are included with
require statements in
application.rb such as:
As of Rails 0.14, the Rails framework has had its own software distribution facility, know as plug-ins.
A plug-in consists of as series of files and directories that each
perform a role in the administration or usage of the plug-in. Perhaps
the most important file of the plug-in architecture is init.rb, which is read when your Rails
application starts up. This file is often used to include other code
required by the plug-in. Most plug-ins also have a lib directory, which is automatically added
to the application’s
Installing a plug-in is as simple as placing it the vendor/plugins directory and restarting your application. When a Rails application is first loaded, a file named init.rb is run for each plug-in in the plug-ins directory. ...