Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Thanks a lot Pascal, this was really useful to me. I noticed a similar behavior when setting up my nested resources.</p> <p>I would add something, the option of using a block statement for shallow instead of a parameter. Right now using the syntax you gave, only the direct descendants (:pages) will be shallow.</p> <p>If by any chance you want to nest one level deeper (let's skip the argument about whether this is best practices or not), using a shallow block will carry the shallowness as deep as necessary:</p> <pre class="lang-rb prettyprint-override"><code>resources :users do shallow do resources :categories do resources :sections do resources :pages end end resources :news end end </code></pre> <p>Here's an example of what available routes helpers you will have for all of the resources nested within :users</p> <pre><code>new_category_section GET (/:locale)(/:locale)/categorys/:category_id/sections/new(.:format) {:locale=&gt;/fr|en/, :action=&gt;"new", :controller=&gt;"sections"} edit_section GET (/:locale)(/:locale)/sections/:id/edit(.:format) {:locale=&gt;/fr|en/, :action=&gt;"edit", :controller=&gt;"sections"} section GET (/:locale)(/:locale)/sections/:id(.:format) {:locale=&gt;/fr|en/, :action=&gt;"show", :controller=&gt;"sections"} PUT (/:locale)(/:locale)/sections/:id(.:format) {:locale=&gt;/fr|en/, :action=&gt;"update", :controller=&gt;"sections"} DELETE (/:locale)(/:locale)/sections/:id(.:format) {:locale=&gt;/fr|en/, :action=&gt;"destroy", :controller=&gt;"sections"} section_pages GET (/:locale)(/:locale)/sections/:section_id/pages(.:format) {:locale=&gt;/fr|en/, :action=&gt;"index", :controller=&gt;"pages"} POST (/:locale)(/:locale)/sections/:section_id/pages(.:format) {:locale=&gt;/fr|en/, :action=&gt;"create", :controller=&gt;"pages"} new_section_info_page GET (/:locale)(/:locale)/sections/:section_id/pages/new(.:format) {:locale=&gt;/fr|en/, :action=&gt;"new", :controller=&gt;"pages"} dit_info_page GET (/:locale)(/:locale)/pages/:id/edit(.:format) {:locale=&gt;/fr|en/, :action=&gt;"edit", :controller=&gt;"pages"} info_page GET (/:locale)(/:locale)/pages/:id(.:format) {:locale=&gt;/fr|en/, :action=&gt;"show", :controller=&gt;"pages"} PUT (/:locale)(/:locale)/pages/:id(.:format) {:locale=&gt;/fr|en/, :action=&gt;"update", :controller=&gt;"pages"} DELETE (/:locale)(/:locale)/pages/:id(.:format) {:locale=&gt;/fr|en/, :action=&gt;"destroy", :controller=&gt;"pages"} </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload