mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Update snippet to rails 5 syntax
This commit is contained in:
parent
81bbcea6cd
commit
4c15ed7753
1 changed files with 1 additions and 1 deletions
|
@ -166,7 +166,7 @@ NOTE: Support for parsing XML parameters has been extracted into a gem named `ac
|
||||||
The `params` hash will always contain the `:controller` and `:action` keys, but you should use the methods `controller_name` and `action_name` instead to access these values. Any other parameters defined by the routing, such as `:id`, will also be available. As an example, consider a listing of clients where the list can show either active or inactive clients. We can add a route which captures the `:status` parameter in a "pretty" URL:
|
The `params` hash will always contain the `:controller` and `:action` keys, but you should use the methods `controller_name` and `action_name` instead to access these values. Any other parameters defined by the routing, such as `:id`, will also be available. As an example, consider a listing of clients where the list can show either active or inactive clients. We can add a route which captures the `:status` parameter in a "pretty" URL:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
get '/clients/:status' => 'clients#index', foo: 'bar'
|
get '/clients/:status', to: 'clients#index', foo: 'bar'
|
||||||
```
|
```
|
||||||
|
|
||||||
In this case, when a user opens the URL `/clients/active`, `params[:status]` will be set to "active". When this route is used, `params[:foo]` will also be set to "bar", as if it were passed in the query string. Your controller will also receive `params[:action]` as "index" and `params[:controller]` as "clients".
|
In this case, when a user opens the URL `/clients/active`, `params[:status]` will be set to "active". When this route is used, `params[:foo]` will also be set to "bar", as if it were passed in the query string. Your controller will also receive `params[:action]` as "index" and `params[:controller]` as "clients".
|
||||||
|
|
Loading…
Reference in a new issue