aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/generators.textile
diff options
context:
space:
mode:
authorJames Strocel <James.Strocel@gmail.com>2012-04-24 12:08:05 -0700
committerJames Strocel <James.Strocel@gmail.com>2012-04-24 12:08:05 -0700
commitf45f1bacb03421094ef3cca9cd541cc41798586c (patch)
treee2d3a3ccab8654a6d974e4ccbaad8e1b2af93d44 /guides/source/generators.textile
parent52188c77f12ebe3c54c2d7ff88982a49aaac260b (diff)
downloadrails-f45f1bacb03421094ef3cca9cd541cc41798586c.tar.gz
rails-f45f1bacb03421094ef3cca9cd541cc41798586c.tar.bz2
rails-f45f1bacb03421094ef3cca9cd541cc41798586c.zip
Added some useful methods to the generators.textile
Diffstat (limited to 'guides/source/generators.textile')
-rw-r--r--guides/source/generators.textile21
1 files changed, 21 insertions, 0 deletions
diff --git a/guides/source/generators.textile b/guides/source/generators.textile
index 920ff997ae..836f3d8549 100644
--- a/guides/source/generators.textile
+++ b/guides/source/generators.textile
@@ -451,6 +451,27 @@ Adds a specified source to +Gemfile+:
add_source "http://gems.github.com"
</ruby>
+h4. +inject_into_file+
+
+Injects a block of code into a defined position in your file.
+
+<ruby>
+inject_into_file 'name_of_file.rb', :after => "#The code goes below this line. Don't for get the Line break at the end\n" do <<-'RUBY'
+ puts "Hello World"
+RUBY
+end
+</ruby>
+
+h4. +gsub_file+
+
+Replaces text inside a file.
+
+<ruby>
+ gsub_file 'name_of_file.rb', 'method.to_be_replaced', 'method.the_replacing_code'
+</ruby
+
+Regular Expressions can be used to make this method more precise. You can also use append_file and prepend_file in the same way to place code at the beginning and end of a file respectively.
+
h4. +application+
Adds a line to +config/application.rb+ directly after the application class definition.