提交 e7ba10b9 编写于 作者: C Chris Houhoulis

Fix url_helper examples in testing guide [ci skip]

上级 7097514d
......@@ -1085,16 +1085,16 @@ The `get` method kicks off the web request and populates the results into the `@
All of these keyword arguments are optional.
Example: Calling the `:show` action, passing an `id` of 12 as the `params` and setting `HTTP_REFERER` header:
Example: Calling the `:show` action for the first `Article`, passing in an `HTTP_REFERER` header:
```ruby
get article_url, params: { id: 12 }, headers: { "HTTP_REFERER" => "http://example.com/home" }
get article_url(Article.first), headers: { "HTTP_REFERER" => "http://example.com/home" }
```
Another example: Calling the `:update` action, passing an `id` of 12 as the `params` as an Ajax request.
Another example: Calling the `:update` action for the last `Article`, passing in new text for the `title` in `params`, as an Ajax request:
```ruby
patch article_url, params: { id: 12 }, xhr: true
patch article_url(Article.last), params: { article: { title: "updated" } }, xhr: true
```
NOTE: If you try running `test_should_create_article` test from `articles_controller_test.rb` it will fail on account of the newly added model level validation and rightly so.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册