aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2011-06-08 15:01:19 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2011-06-08 15:01:19 +0530
commitdef4a538cc56760365d1fc0840dc33c09def0db8 (patch)
treec5622fd3a8eb3384f9b4779544d1577ec67845f9 /railties/guides
parent5c53754f330219bd32d5793e71f516fba62f32bf (diff)
downloadrails-def4a538cc56760365d1fc0840dc33c09def0db8.tar.gz
rails-def4a538cc56760365d1fc0840dc33c09def0db8.tar.bz2
rails-def4a538cc56760365d1fc0840dc33c09def0db8.zip
remove generators section from command line guide in favor of the separate generator guide
Diffstat (limited to 'railties/guides')
-rw-r--r--railties/guides/source/command_line.textile94
1 files changed, 0 insertions, 94 deletions
diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile
index 2fe5be43b1..026c15feba 100644
--- a/railties/guides/source/command_line.textile
+++ b/railties/guides/source/command_line.textile
@@ -504,97 +504,3 @@ $ rails server mongrel
=> Rails 3.1.0 application starting on http://0.0.0.0:3000
...
</shell>
-
-h4. The Rails Generation: Generators
-
-INFO: For a good rundown on generators, see "Understanding Generators":generators.html. A lot of its material is presented here.
-
-Generators are code that generates code. Let's experiment by building one. Our generator will generate a text file.
-
-The Rails generator by default looks in these places for available generators, where Rails.root is the root of your Rails application, like /home/foobar/commandsapp:
-
-* Rails.root/lib/generators
-* Rails.root/vendor/generators
-* Inside any plugin with a directory like "generators" or "rails_generators"
-* ~/.rails/generators
-* Inside any Gem you have installed with a name ending in "_generator"
-* Inside any Gem installed with a "rails_generators" path, and a file ending in "_generator.rb"
-* Finally, the builtin Rails generators (controller, model, mailer, etc.)
-
-Let's try the fourth option (in our home directory), which will be easy to clean up later:
-
-<shell>
-$ mkdir -p ~/.rails/generators/tutorial_test/templates
-$ touch ~/.rails/generators/tutorial_test/templates/tutorial.erb
-$ touch ~/.rails/generators/tutorial_test/tutorial_test_generator.rb
-</shell>
-
-We'll fill +tutorial_test_generator.rb+ out with:
-
-<ruby>
-class TutorialTestGenerator < Rails::Generator::Base
- def initialize(*runtime_args)
- super(*runtime_args)
- @tut_args = runtime_args
- end
-
- def manifest
- record do |m|
- m.directory "public"
- m.template "tutorial.erb", File.join("public", "tutorial.txt"),
- :assigns => { :args => @tut_args }
- end
- end
-end
-</ruby>
-
-We take whatever args are supplied, save them to an instance variable, and literally copying from the Rails source, implement a +manifest+ method, which calls +record+ with a block, and we:
-
-* Check there's a *public* directory. You bet there is.
-* Run the ERB template called "tutorial.erb".
-* Save it into "Rails.root/public/tutorial.txt".
-* Pass in the arguments we saved through the +:assigns+ parameter.
-
-Next we'll build the template:
-
-<shell>
-$ cat ~/.rails/generators/tutorial_test/templates/tutorial.erb
-I'm a template!
-
-I got assigned some args:
-<%= require 'pp'; PP.pp(args, "") %>
-</shell>
-
-Then we'll make sure it got included in the list of available generators:
-
-<shell>
-$ rails generate
-...
-...
-Installed Generators
- User: tutorial_test
-</shell>
-
-SWEET! Now let's generate some text, yeah!
-
-<shell>
-$ rails generate tutorial_test arg1 arg2 arg3
- exists public
- create public/tutorial.txt
-</shell>
-
-And the result:
-
-<shell>
-$ cat public/tutorial.txt
-I'm a template!
-
-I got assigned some args:
-[["arg1", "arg2", "arg3"],
- {:collision=>:ask,
- :quiet=>false,
- :generator=>"tutorial_test",
- :command=>:create}]
-</shell>
-
-Tada!