diff options
author | Xavier Noria <fxn@hashref.com> | 2011-03-07 22:11:47 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2011-03-07 22:11:47 +0100 |
commit | 89ecc0a5dc1d06a6bbd2a59edd57187c6eedf8af (patch) | |
tree | 762f7860f65b7e058016707ef6771b1ff2feb7cb /railties/guides/source/generators.textile | |
parent | 5968d7a65886d3450698889f685eccaf54749f43 (diff) | |
parent | f99db5a6a8295b463325accaefe53ab6c89c9982 (diff) | |
download | rails-89ecc0a5dc1d06a6bbd2a59edd57187c6eedf8af.tar.gz rails-89ecc0a5dc1d06a6bbd2a59edd57187c6eedf8af.tar.bz2 rails-89ecc0a5dc1d06a6bbd2a59edd57187c6eedf8af.zip |
Merge branch 'master' of git://github.com/lifo/docrails
Diffstat (limited to 'railties/guides/source/generators.textile')
-rw-r--r-- | railties/guides/source/generators.textile | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/railties/guides/source/generators.textile b/railties/guides/source/generators.textile index fc7b1216d5..d32ba48003 100644 --- a/railties/guides/source/generators.textile +++ b/railties/guides/source/generators.textile @@ -34,7 +34,7 @@ $ rails generate helper --help h3. Creating Your First Generator -Since Rails 3.0, generators are built on top of "Thor":http://github.com/wycats/thor. Thor provides powerful options parsing and a great API for manipulating files. For instance, let's build a generator that creates an initializer file named +initializer.rb+ inside +config/initializers+. +Since Rails 3.0, generators are built on top of "Thor":https://github.com/wycats/thor. Thor provides powerful options parsing and a great API for manipulating files. For instance, let's build a generator that creates an initializer file named +initializer.rb+ inside +config/initializers+. The first step is to create a file at +lib/generators/initializer_generator.rb+ with the following content: @@ -319,7 +319,7 @@ If you generate another resource, you can see that we get exactly the same resul h3. Adding Generators Fallbacks -One last feature about generators which is quite useful for plugin generators is fallbacks. For example, imagine that you want to add a feature on top of TestUnit like "shoulda":http://github.com/thoughtbot/shoulda does. Since TestUnit already implements all generators required by Rails and shoulda just wants to overwrite part of it, there is no need for shoulda to reimplement some generators again, it can simply tell Rails to use a +TestUnit+ generator if none was found under the +Shoulda+ namespace. +One last feature about generators which is quite useful for plugin generators is fallbacks. For example, imagine that you want to add a feature on top of TestUnit like "shoulda":https://github.com/thoughtbot/shoulda does. Since TestUnit already implements all generators required by Rails and shoulda just wants to overwrite part of it, there is no need for shoulda to reimplement some generators again, it can simply tell Rails to use a +TestUnit+ generator if none was found under the +Shoulda+ namespace. We can easily simulate this behavior by changing our +config/application.rb+ once again: |