Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 7f24653e7a
Fetching contributors…

Cannot retrieve contributors at this time

49 lines (31 sloc) 1.787 kb
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::preparation.txt[]
include::string_to_squawk.txt[]
include::acts_as_yaffle.txt[]
include::view_helper.txt[]
include::migration_generator.txt[]
include::custom_generator.txt[]
include::custom_route.txt[]
include::odds_and_ends.txt[]
include::appendix.txt[]
Jump to Line
Something went wrong with that request. Please try again.