Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

explain how to extend application templates. [ci skip]

  • Loading branch information...
commit 3196ceaba28be64d890e9544af218481ad54cf16 1 parent e94be7b
Yves Senn senny authored
Showing with 19 additions and 0 deletions.
  1. +19 −0 guides/source/rails_application_templates.md
19 guides/source/rails_application_templates.md
View
@@ -227,3 +227,22 @@ git :init
git add: "."
git commit: "-a -m 'Initial commit'"
```
+
+Advanced Usage
+--------------
+
+The application template is evaluated in the context of a
+`Rails::Generators::AppGenerator` instance. It uses the `apply` action
+provided by
+[Thor](https://github.com/erikhuda/thor/blob/master/lib/thor/actions.rb#L207).
+This means you can extend and change the instance to match your needs.
+
+For example by overwriting the `source_paths` method to contain the
+location of your template. Now methods like `copy_file` will accept
+relative paths to your template's location.
+
+```ruby
+def source_paths
+ [File.expand_path(File.dirname(__FILE__))]
+end
+```
Please sign in to comment.
Something went wrong with that request. Please try again.