diff options
author | aditya-kapoor <aditya.kapoor@vinsol.com> | 2013-12-10 11:44:07 +0530 |
---|---|---|
committer | aditya-kapoor <aditya.kapoor@vinsol.com> | 2013-12-10 11:44:07 +0530 |
commit | 0c55335074ed7baf2f165ada168f726f1f7bba68 (patch) | |
tree | 2a8428d72f6890cb0eb6c5b9b1d40b7b2ce93d8b /guides/source/plugins.md | |
parent | 6b9b0767bf480d53029afeb3f8e86f66e933fb41 (diff) | |
parent | fe077b50c9ce65c4ac1cc718c34dda45cd24c6fe (diff) | |
download | rails-0c55335074ed7baf2f165ada168f726f1f7bba68.tar.gz rails-0c55335074ed7baf2f165ada168f726f1f7bba68.tar.bz2 rails-0c55335074ed7baf2f165ada168f726f1f7bba68.zip |
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'guides/source/plugins.md')
-rw-r--r-- | guides/source/plugins.md | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/guides/source/plugins.md b/guides/source/plugins.md index b52504b104..d0aa2e55a2 100644 --- a/guides/source/plugins.md +++ b/guides/source/plugins.md @@ -15,7 +15,7 @@ After reading this guide, you will know: 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 methods to `ActiveRecord::Base` in the tradition of the `acts_as` plugins. * Give you information about where to put generators in your plugin. For the purpose of this guide pretend for a moment that you are an avid bird watcher. @@ -34,9 +34,15 @@ different rails applications using RubyGems and Bundler if desired. Rails ships with a `rails plugin new` command which creates a - skeleton for developing any kind of Rails extension with the ability - to run integration tests using a dummy Rails application. See usage - and options by asking for help: +skeleton for developing any kind of Rails extension with the ability +to run integration tests using a dummy Rails application. Create your +plugin with the command: + +```bash +$ rails plugin new yaffle +``` + +See usage and options by asking for help: ```bash $ rails plugin --help @@ -126,8 +132,8 @@ $ rails console Add an "acts_as" Method to Active Record ---------------------------------------- -A common pattern in plugins is to add a method called 'acts_as_something' to models. In this case, you -want to write a method called 'acts_as_yaffle' that adds a 'squawk' method to your Active Record models. +A common pattern in plugins is to add a method called `acts_as_something` to models. In this case, you +want to write a method called `acts_as_yaffle` that adds a `squawk` method to your Active Record models. To begin, set up your files so that you have: @@ -162,9 +168,9 @@ end ### Add a Class Method -This plugin will expect that you've added a method to your model named 'last_squawk'. However, the -plugin users might have already defined a method on their model named 'last_squawk' that they use -for something else. This plugin will allow the name to be changed by adding a class method called 'yaffle_text_field'. +This plugin will expect that you've added a method to your model named `last_squawk`. However, the +plugin users might have already defined a method on their model named `last_squawk` that they use +for something else. This plugin will allow the name to be changed by adding a class method called `yaffle_text_field`. To start out, write a failing test that shows the behavior you'd like: |