aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorclaudiob <claudiob@gmail.com>2016-02-20 09:56:35 -0800
committerclaudiob <claudiob@gmail.com>2016-02-20 10:01:55 -0800
commit1a5941e3cfb67056a9468d590f8ae03485f75ccc (patch)
treea018ded99f6afc44c2d113c2d29e602935ab0251 /guides/source
parente76891314126b10d5cf57aaf776dfa2a26553ec3 (diff)
downloadrails-1a5941e3cfb67056a9468d590f8ae03485f75ccc.tar.gz
rails-1a5941e3cfb67056a9468d590f8ae03485f75ccc.tar.bz2
rails-1a5941e3cfb67056a9468d590f8ae03485f75ccc.zip
AppGenerator: Replace 'rake' with 'rails_command'
Since Rails 5.0 is switching the Rails command line from 'rake …' to 'rails …', it makes sense to also replace the `rake` method in the Rails templates API. Based on feedback from @matthewd and @kaspth, I chose to replace `rake` with `rails_command`, which is less confusing than the alternatives `rails` or `command` or `rails_run` and is not Thor-reserved word like `task`.
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/rails_application_templates.md22
1 files changed, 14 insertions, 8 deletions
diff --git a/guides/source/rails_application_templates.md b/guides/source/rails_application_templates.md
index 5a46baff2d..3bb5d3c8a6 100644
--- a/guides/source/rails_application_templates.md
+++ b/guides/source/rails_application_templates.md
@@ -22,7 +22,7 @@ $ rails new blog -m ~/template.rb
$ rails new blog -m http://example.com/template.rb
```
-You can use the rake task `rails:template` to apply templates to an existing Rails application. The location of the template needs to be passed in to an environment variable named LOCATION. Again, this can either be path to a file or a URL.
+You can use the task `rails:template` to apply templates to an existing Rails application. The location of the template needs to be passed in to an environment variable named LOCATION. Again, this can either be path to a file or a URL.
```bash
$ bin/rails rails:template LOCATION=~/template.rb
@@ -38,7 +38,7 @@ The Rails templates API is easy to understand. Here's an example of a typical Ra
# template.rb
generate(:scaffold, "person name:string")
route "root to: 'people#index'"
-rake("db:migrate")
+rails_command("db:migrate")
after_bundle do
git :init
@@ -175,18 +175,24 @@ Executes an arbitrary command. Just like the backticks. Let's say you want to re
run "rm README.rdoc"
```
-### rake(command, options = {})
+### rails_command(command, options = {})
-Runs the supplied rake tasks in the Rails application. Let's say you want to migrate the database:
+Runs the supplied task in the Rails application. Let's say you want to migrate the database:
```ruby
-rake "db:migrate"
+rails_command "db:migrate"
```
-You can also run rake tasks with a different Rails environment:
+You can also run tasks with a different Rails environment:
```ruby
-rake "db:migrate", env: 'production'
+rails_command "db:migrate", env: 'production'
+```
+
+You can also run tasks as a super-user:
+
+```ruby
+rails_command "log:clear", sudo: true
```
### route(routing_code)
@@ -226,7 +232,7 @@ CODE
These methods let you ask questions from templates and decide the flow based on the user's answer. Let's say you want to Freeze Rails only if the user wants to:
```ruby
-rake("rails:freeze:gems") if yes?("Freeze rails gems?")
+rails_command("rails:freeze:gems") if yes?("Freeze rails gems?")
# no?(question) acts just the opposite.
```