Skip to content

Commit 0b44228

Browse files
authored
Logic for nested routes support (#53)
This logic assumes the parent resource has a `nested_routes` class method. For example: ```ruby resources :resources, module: :content, only: %w[show] do resource :template, path: "template.rb", module: :resources, only: %w[show] end ``` Then the class: ```ruby class Content::Resource < Perron::Resource def self.nested_routes = [:template] end ```
1 parent 8a0f8f0 commit 0b44228

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/perron/site/builder/paths.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ def get
1818
next if skip? root
1919

2020
@paths << (root ? routes.root_path : routes.public_send(show_path, resource))
21+
22+
(resource.class.try(:nested_routes) || []).each do |nested|
23+
@paths << routes.polymorphic_path([resource, nested])
24+
end
2125
end
2226
end
2327
end

0 commit comments

Comments
 (0)