Ruby on Rails - use of shallow in ruby on rails- ruby on rails tutorial - rails guides - rails tutorial - ruby rails
Use of shallow
Example
- One way to avoid deep nesting (as recommended above) is to generate the collection actions scoped under the parent,
- so as to get a sense of the hierarchy, but to not nest the member actions. In other words, to only build routes with the minimal amount of information to uniquely identify the resource.
resources :articles, shallow: true do
resources :comments
resources :quotes
resources :drafts
endClicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team
- The shallow method of the DSL creates a scope inside of which every nesting is shallow.
- This generates the same routes from above example:
shallow do
resources :articles do
resources :comments
resources :quotes
resources :drafts
end
endClicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team
- There exist two options for scope to customize shallow routes. :shallow_path prefixes member paths with the specified parameter.
scope shallow_path: "sekret" do
resources :articles do
resources :comments, shallow: true
end
endClicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team
Rake Command:
- It used for get generated routes as given below:
rake routes