Question: How does :as works in the rails routing. Say, I have following code 

```
get '/patients/:id', to: 'patients#show', as: 'patient'

```

I understand that when rails get `/patients/:id` it will perform show action of patient controller but what to do with as here? I already read the guide but didn't understand it.

Answer: 
When you declare `as: 'patient'` you can reference this route in you view as: `patient_path` or `patient_url`, in other words it's a named route.
`:as` forms a named route.

`as: patient` will create `patient_path` and `patient_url` as named helpers in your application. Calling `patient_path` will redirect to show page.

in view you can use it like this

```
<%= link_to "Show patient", patient_path %>

```

[naming-routes](http://guides.rubyonrails.org/routing.html#naming-routes)