Source

RubyLearning / ProjectTrak / vendor / rails / railties / doc / guides / source / creating_plugins / index.txt

Full commit
The Basics of Creating Rails Plugins
====================================

A Rails plugin is either an extension or a modification of the core framework. Plugins provide:

 * a way for developers to share bleeding-edge ideas without hurting the stable code base
 * a segmented architecture so that units of code can be fixed or updated on their own release schedule
 * an outlet for the core developers so that they don’t have to include every cool new feature under the sun

After reading this guide you should be familiar with:
 
 * Creating a plugin from scratch
 * Writing and running tests for the plugin
 * Storing models, views, controllers, helpers and even other plugins in your plugins
 * Writing generators
 * Writing custom Rake tasks in your plugin
 * Generating RDoc documentation for your plugin
 * Avoiding common pitfalls with 'init.rb'

This guide describes how to build a test-driven plugin that will:

 * Extend core ruby classes like Hash and String
 * Add methods to ActiveRecord::Base in the tradition of the 'acts_as' plugins
 * Add a view helper that can be used in erb templates
 * Add a new generator that will generate a migration
 * Add a custom generator command
 * A custom route method that can be used in routes.rb

For the purpose of this guide pretend for a moment that you are an avid bird watcher.  Your favorite bird is the Yaffle, and you want to create a plugin that allows other developers to share in the Yaffle goodness.  First, you need to get setup for development.


include::test_setup.txt[]

include::core_ext.txt[]

include::acts_as_yaffle.txt[]

include::migration_generator.txt[]

include::generator_method.txt[]

include::models.txt[]

include::controllers.txt[]

include::helpers.txt[]

include::custom_route.txt[]

include::odds_and_ends.txt[]

include::appendix.txt[]