1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

explain how to extend application templates. [ci skip]

This commit is contained in:
Yves Senn 2013-07-05 13:21:01 +02:00
parent e94be7b04c
commit 3196ceaba2

View file

@ -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
```