aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/active_job_basics.md17
-rw-r--r--guides/source/active_record_basics.md2
-rw-r--r--guides/source/asset_pipeline.md8
-rw-r--r--guides/source/getting_started.md11
-rw-r--r--guides/source/testing.md20
5 files changed, 32 insertions, 26 deletions
diff --git a/guides/source/active_job_basics.md b/guides/source/active_job_basics.md
index cb25a4c5f3..e3502d7363 100644
--- a/guides/source/active_job_basics.md
+++ b/guides/source/active_job_basics.md
@@ -70,12 +70,14 @@ Here's what a job looks like:
class GuestsCleanupJob < ActiveJob::Base
queue_as :default
- def perform(*args)
+ def perform(*guests)
# Do something later
end
end
```
+Note that you can define `perform` with as many arguments as you want.
+
### Enqueue the Job
Enqueue a job like so:
@@ -83,21 +85,26 @@ Enqueue a job like so:
```ruby
# Enqueue a job to be performed as soon the queuing system is
# free.
-MyJob.perform_later record
+GuestsCleanupJob.perform_later guest
```
```ruby
# Enqueue a job to be performed tomorrow at noon.
-MyJob.set(wait_until: Date.tomorrow.noon).perform_later(record)
+GuestsCleanupJob.set(wait_until: Date.tomorrow.noon).perform_later(guest)
```
```ruby
# Enqueue a job to be performed 1 week from now.
-MyJob.set(wait: 1.week).perform_later(record)
+GuestsCleanupJob.set(wait: 1.week).perform_later(guest)
```
-That's it!
+```ruby
+# `perform_now` and `perform_later` will call `perform` under the hood so
+# you can pass as many arguments as defined in the latter.
+GuestsCleanupJob.perform_later(guest1, guest2, filter: 'some_filter')
+```
+That's it!
Job Execution
-------------
diff --git a/guides/source/active_record_basics.md b/guides/source/active_record_basics.md
index f4baf92228..dafbe17bbd 100644
--- a/guides/source/active_record_basics.md
+++ b/guides/source/active_record_basics.md
@@ -142,7 +142,7 @@ end
This will create a `Product` model, mapped to a `products` table at the
database. By doing this you'll also have the ability to map the columns of each
row in that table with the attributes of the instances of your model. Suppose
-that the `products` table was created using an SQL sentence like:
+that the `products` table was created using an SQL statement like:
```sql
CREATE TABLE products (
diff --git a/guides/source/asset_pipeline.md b/guides/source/asset_pipeline.md
index fc7dd3a6c6..7b8d2d3aef 100644
--- a/guides/source/asset_pipeline.md
+++ b/guides/source/asset_pipeline.md
@@ -403,13 +403,13 @@ When using the asset pipeline, paths to assets must be re-written and
underscored in Ruby) for the following asset classes: image, font, video, audio,
JavaScript and stylesheet.
-* `url(/assets/rails.png)` becomes `image-url("rails.png")`
-* `"/assets/rails.png"` becomes `image-path("rails.png")` .
+* `image-url("rails.png")` returns `url(/assets/rails.png)`
+* `image-path("rails.png")` returns `"/assets/rails.png"`
The more generic form can also be used:
-* `url(/assets/rails.png)` becomes `asset-url("rails.png")`
-* `"/assets/rails.png"` becomes `asset-path("rails.png")`
+* `asset-url("rails.png")` returns `url(/assets/rails.png)`
+* `asset-path("rails.png")` returns `"/assets/rails.png"`
#### JavaScript/CoffeeScript and ERB
diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md
index d51a27812a..ef66b75ec1 100644
--- a/guides/source/getting_started.md
+++ b/guides/source/getting_started.md
@@ -37,7 +37,6 @@ curve diving straight into Rails. There are several curated lists of online reso
for learning Ruby:
* [Official Ruby Programming Language website](https://www.ruby-lang.org/en/documentation/)
-* [reSRC's List of Free Programming Books](http://resrc.io/list/10/list-of-free-programming-books/#ruby)
Be aware that some resources, while still excellent, cover versions of Ruby as old as
1.6, and commonly 1.8, and will not include some syntax that you will see in day-to-day
@@ -92,17 +91,17 @@ Open up a command line prompt. On Mac OS X open Terminal.app, on Windows choose
dollar sign `$` should be run in the command line. Verify that you have a
current version of Ruby installed:
+```bash
+$ ruby -v
+ruby 2.2.2p95
+```
+
TIP: A number of tools exist to help you quickly install Ruby and Ruby
on Rails on your system. Windows users can use [Rails Installer](http://railsinstaller.org),
while Mac OS X users can use [Tokaido](https://github.com/tokaido/tokaidoapp).
For more installation methods for most Operating Systems take a look at
[ruby-lang.org](https://www.ruby-lang.org/en/documentation/installation/).
-```bash
-$ ruby -v
-ruby 2.2.2p95
-```
-
Many popular UNIX-like OSes ship with an acceptable version of SQLite3.
On Windows, if you installed Rails through Rails Installer, you
already have SQLite installed. Others can find installation instructions
diff --git a/guides/source/testing.md b/guides/source/testing.md
index f40e765242..0f24bd0311 100644
--- a/guides/source/testing.md
+++ b/guides/source/testing.md
@@ -443,8 +443,8 @@ specify to make your test failure messages clearer. It's not required.
| `assert_no_match( regexp, string, [msg] )` | Ensures that a string doesn't match the regular expression.|
| `assert_includes( collection, obj, [msg] )` | Ensures that `obj` is in `collection`.|
| `assert_not_includes( collection, obj, [msg] )` | Ensures that `obj` is not in `collection`.|
-| `assert_in_delta( expecting, actual, [delta], [msg] )` | Ensures that the numbers `expected` and `actual` are within `delta` of each other.|
-| `assert_not_in_delta( expecting, actual, [delta], [msg] )` | Ensures that the numbers `expected` and `actual` are not within `delta` of each other.|
+| `assert_in_delta( expected, actual, [delta], [msg] )` | Ensures that the numbers `expected` and `actual` are within `delta` of each other.|
+| `assert_not_in_delta( expected, actual, [delta], [msg] )` | Ensures that the numbers `expected` and `actual` are not within `delta` of each other.|
| `assert_throws( symbol, [msg] ) { block }` | Ensures that the given block throws the symbol.|
| `assert_raises( exception1, exception2, ... ) { block }` | Ensures that the given block raises one of the given exceptions.|
| `assert_nothing_raised( exception1, exception2, ... ) { block }` | Ensures that the given block doesn't raise one of the given exceptions.|
@@ -530,7 +530,7 @@ Let me take you through one such test, `test_should_get_index` from the file `ar
```ruby
# articles_controller_test.rb
class ArticlesControllerTest < ActionController::TestCase
- test "should get index" do
+ def test_should_get_index
get :index
assert_response :success
assert_includes @response.body, 'Articles'
@@ -572,7 +572,7 @@ NOTE: If you try running `test_should_create_article` test from `articles_contro
Let us modify `test_should_create_article` test in `articles_controller_test.rb` so that all our test pass:
```ruby
-test "should create article" do
+def test_should_create_article
assert_difference('Article.count') do
post :create, params: { article: { title: 'Some title' } }
end
@@ -612,9 +612,9 @@ test "ajax request" do
end
```
-### The Four Hashes of the Apocalypse
+### The Three Hashes of the Apocalypse
-After a request has been made and processed, you will have 4 Hash objects ready for use:
+After a request has been made and processed, you will have 3 Hash objects ready for use:
* `cookies` - Any cookies that are set.
* `flash` - Any objects living in the flash.
@@ -655,7 +655,7 @@ post :create # simulate the request with custom env variable
### Testing `flash` notices
-If you remember from earlier one of the Four Hashes of the Apocalypse was `flash`.
+If you remember from earlier one of the Three Hashes of the Apocalypse was `flash`.
We want to add a `flash` message to our blog application whenever someone
successfully creates a new Article.
@@ -663,7 +663,7 @@ successfully creates a new Article.
Let's start by adding this assertion to our `test_should_create_article` test:
```ruby
-test "should create article" do
+test_should_create_article do
assert_difference('Article.count') do
post :create, params: { article: { title: 'Some title' } }
end
@@ -1062,7 +1062,7 @@ end
Let's break this test down so we can understand it.
-We start by calling the `:new` action on our Articles controller. This response should be successful, and we can verify the correct template is rendered including the form partial.
+We start by calling the `:new` action on our Articles controller. This response should be successful.
After this we make a post request to the `:create` action of our Articles controller:
@@ -1077,7 +1077,7 @@ The two lines following the request are to handle the redirect we setup when cre
NOTE: Don't forget to call `follow_redirect!` if you plan to make subsequent requests after a redirect is made.
-Finally we can assert that our response was successful, template was rendered, and our new article is readable on the page.
+Finally we can assert that our response was successful and our new article is readable on the page.
#### Taking it further