diff options
author | Robin Dupret <robin.dupret@gmail.com> | 2015-04-25 13:49:35 +0200 |
---|---|---|
committer | Robin Dupret <robin.dupret@gmail.com> | 2015-04-25 13:53:17 +0200 |
commit | e61f4ea31376bc253acb4c9365f858b01ee8e493 (patch) | |
tree | d91f2351689a738858f8201dcb487cb80769f358 | |
parent | 2fab16142ee1c1d5f08b49b9fb2b6dd4717397a8 (diff) | |
download | rails-e61f4ea31376bc253acb4c9365f858b01ee8e493.tar.gz rails-e61f4ea31376bc253acb4c9365f858b01ee8e493.tar.bz2 rails-e61f4ea31376bc253acb4c9365f858b01ee8e493.zip |
Minor edits to the "Action View Overview" guide
Follow-up to #19672 and 8b0aa0c1.
[ci skip]
-rw-r--r-- | guides/source/action_view_overview.md | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/guides/source/action_view_overview.md b/guides/source/action_view_overview.md index 44c02165db..f0ff3d8864 100644 --- a/guides/source/action_view_overview.md +++ b/guides/source/action_view_overview.md @@ -356,39 +356,34 @@ Supposing we use the same `_box` partial from above, this would produce the same View Paths ---------- -When rendering the view for a request, the controller needs to resolve where to find each of the directories are located. +When rendering a response, the controller needs to resolve where the different +views are located. By default it only looks inside the `app/views` directory. -We are able to modify the order these locations are resolved by using `prepend_view_path` and `append_view_path`. - -This allows us to add new paths to the beginning or end of the list used to resolve these paths. +We can add other locations and give them a certain precedence when resolving +paths using the `prepend_view_path` and `append_view_path` methods. ### Prepend view path -This can be helpful for example, when we want to prepend a different directory for subdomains. +This can be helpful for example, when we want to put views inside a different +directory for subdomains. We can do this by using: -```prepend_view_path "app/views/#{request.subdomain}"``` - -Then our list becomes something like: - -``` -[ - ~/rails_app/app/views/<subdomain>, - ~/rails_app/app/views, - # ... -] +```ruby +prepend_view_path "app/views/#{request.subdomain}" ``` -This will put the subdomain path at the beginning of the list. +Then Action View will look first in this directory when resolving views. ### Append view path Similarly, we can append paths: -```append_view_path "app/views/direct"```. +```ruby +append_view_path "app/views/direct" +``` -This will add ```app/views/direct``` and the end of lookup paths for views. +This will add `app/views/direct` to the end of the lookup paths. Overview of helpers provided by Action View ------------------------------------------- |