提交 3fccecb8 编写于 作者: T the-undefined 提交者: Joe James

[ci skip] add `controller:` argument to routing.md

Passing a `Symbol` to the `to:` argument for a `get` route requires a `controller` argument to also be defined.
The documentation is missing the `controller:` argument, which leaving out raises a routing exception:

```ruby
get 'profile', to: :show
```

```
$ rake routes
ArgumentError: Missing :controller key on routes definition, please check your routes.
```

Adding the `controller:` argument maps the route correctly:

```ruby
get 'profile', to: :show, controller: 'users'
```
```
$ rake routes
profile GET    /profile(.:format)  users#show
```
上级 b6537e43
......@@ -142,10 +142,10 @@ Sometimes, you have a resource that clients always look up without referencing a
get 'profile', to: 'users#show'
```
Passing a `String` to `get` will expect a `controller#action` format, while passing a `Symbol` will map directly to an action:
Passing a `String` to `get` will expect a `controller#action` format, while passing a `Symbol` will map directly to an action but you must also specify the `controller:` to use:
```ruby
get 'profile', to: :show
get 'profile', to: :show, controller: 'users'
```
This resourceful route:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册