aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/rails_application_templates.md
diff options
context:
space:
mode:
Diffstat (limited to 'guides/source/rails_application_templates.md')
-rw-r--r--guides/source/rails_application_templates.md34
1 files changed, 23 insertions, 11 deletions
diff --git a/guides/source/rails_application_templates.md b/guides/source/rails_application_templates.md
index ee5fbcfd52..6cd19eb8e9 100644
--- a/guides/source/rails_application_templates.md
+++ b/guides/source/rails_application_templates.md
@@ -36,17 +36,17 @@ Rails templates API is very self explanatory and easy to understand. Here's an e
# template.rb
run "rm public/index.html"
generate(:scaffold, "person name:string")
-route "root :to => 'people#index'"
+route "root to: 'people#index'"
rake("db:migrate")
git :init
-git :add => "."
-git :commit => %Q{ -m 'Initial commit' }
+git add: "."
+git commit: %Q{ -m 'Initial commit' }
```
The following sections outlines the primary methods provided by the API:
-### gem(name, options = {})
+### gem(*args)
Adds a `gem` entry for the supplied gem to the generated application’s `Gemfile`.
@@ -85,6 +85,18 @@ For example, if you need to source a gem from "http://code.whytheluckystiff.net"
add_source "http://code.whytheluckystiff.net"
```
+### environment/application(data=nil, options={}, &block)
+
+Adds a line inside the `Application` class for `config/application.rb`.
+
+If `options[:env]` is specified, the line is appended to the corresponding file in `config/environments`.
+
+```ruby
+environment 'config.action_mailer.default_url_options = {host: 'http://yourwebsite.example.com'}, env: 'production'
+```
+
+A block can be used in place of the `data` argument.
+
### vendor/lib/file/initializer(filename, data = nil, &block)
Adds an initializer to the generated application’s `config/initializers` directory.
@@ -136,7 +148,7 @@ end
The above creates `lib/tasks/bootstrap.rake` with a `boot:strap` rake task.
-### generate(what, args)
+### generate(what, *args)
Runs the supplied rails generator with given arguments.
@@ -163,15 +175,15 @@ rake "db:migrate"
You can also run rake tasks with a different Rails environment:
```ruby
-rake "db:migrate", :env => 'production'
+rake "db:migrate", env: 'production'
```
### route(routing_code)
-This adds a routing entry to the `config/routes.rb` file. In above steps, we generated a person scaffold and also removed `public/index.html`. Now to make `PeopleController#index` as the default page for the application:
+Adds a routing entry to the `config/routes.rb` file. In above steps, we generated a person scaffold and also removed `public/index.html`. Now to make `PeopleController#index` as the default page for the application:
```ruby
-route "root :to => 'person#index'"
+route "root to: 'person#index'"
```
### inside(dir)
@@ -203,7 +215,7 @@ CODE
These methods let you ask questions from templates and decide the flow based on the user’s answer. Lets say you want to freeze rails only if the user want to:
```ruby
-rake("rails:freeze:gems") if yes?("Freeze rails gems ?")
+rake("rails:freeze:gems") if yes?("Freeze rails gems?")
# no?(question) acts just the opposite.
```
@@ -213,6 +225,6 @@ Rails templates let you run any git command:
```ruby
git :init
-git :add => "."
-git :commit => "-a -m 'Initial commit'"
+git add: "."
+git commit: "-a -m 'Initial commit'"
```