diff options
author | Zachary Scott <e@zzak.io> | 2015-04-12 14:43:49 -0700 |
---|---|---|
committer | Zachary Scott <e@zzak.io> | 2015-04-12 14:43:49 -0700 |
commit | 41541b58cb05d278a20487f447af3798480ab210 (patch) | |
tree | cd49c3a7b3a2237f90a6bbd64327cc221601b697 /guides/source | |
parent | 9cabd35d4300208e1e038ee5720cf6ab6fd2018a (diff) | |
parent | 8b0aa0c1b1d695a3105dc3236cc2fbda80d5b536 (diff) | |
download | rails-41541b58cb05d278a20487f447af3798480ab210.tar.gz rails-41541b58cb05d278a20487f447af3798480ab210.tar.bz2 rails-41541b58cb05d278a20487f447af3798480ab210.zip |
Merge branch 'nishantmodak-view_paths'
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/action_view_overview.md | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/guides/source/action_view_overview.md b/guides/source/action_view_overview.md index abf6c0db11..44c02165db 100644 --- a/guides/source/action_view_overview.md +++ b/guides/source/action_view_overview.md @@ -356,7 +356,39 @@ Supposing we use the same `_box` partial from above, this would produce the same View Paths ---------- -TODO... +When rendering the view for a request, the controller needs to resolve where to find each of the directories are located. + +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. + +### Prepend view path + +This can be helpful for example, when we want to prepend 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, + # ... +] +``` + +This will put the subdomain path at the beginning of the list. + +### Append view path + +Similarly, we can append paths: + +```append_view_path "app/views/direct"```. + +This will add ```app/views/direct``` and the end of lookup paths for views. Overview of helpers provided by Action View ------------------------------------------- |