File tree 1 file changed +10
-10
lines changed
1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -11,10 +11,16 @@ def resources
11
11
end
12
12
13
13
def routes
14
- @routes ||= all_routes . select do |controller , _action |
15
- controller . starts_with? ( "#{ namespace } /" )
16
- end . map do |controller , action |
17
- [ controller . gsub ( /^#{ namespace } \/ / , "" ) , action ]
14
+ @routes ||= begin
15
+ prefix = "#{ namespace } /" . freeze
16
+ Rails . application . routes . routes . filter_map do |route |
17
+ next unless route . defaults [ :controller ] &.start_with? ( prefix )
18
+
19
+ [
20
+ route . defaults [ :controller ] . delete_prefix ( prefix ) ,
21
+ route . defaults [ :action ]
22
+ ]
23
+ end
18
24
end
19
25
end
20
26
@@ -25,11 +31,5 @@ def resources_with_index_route
25
31
private
26
32
27
33
attr_reader :namespace
28
-
29
- def all_routes
30
- Rails . application . routes . routes . map do |route |
31
- route . defaults . values_at ( :controller , :action ) . map ( &:to_s )
32
- end
33
- end
34
34
end
35
35
end
You can’t perform that action at this time.
0 commit comments