rails-routes-js-utils 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -34,15 +34,17 @@ module Rails
|
|
34
34
|
all_routes = ENV['CONTROLLER'] ? Rails.Application.routes.select { |route| route.defaults[:controller] == ENV['CONTROLLER'] } : IMuaSam::Application.routes
|
35
35
|
all_routes.routes.collect do |route|
|
36
36
|
compiled_regex = route.path.to_regexp.to_javascript
|
37
|
+
|
38
|
+
#route.defaults contains action and controller name
|
37
39
|
reqs = route.defaults.merge(parts: route.parts)
|
38
40
|
if route.constraints[:subdomain]
|
39
|
-
|
41
|
+
subdomain_regex = route.constraints[:subdomain].to_javascript
|
40
42
|
end
|
41
43
|
|
42
44
|
js = [];
|
43
45
|
dig(route.path.spec,js)
|
44
46
|
if route.name
|
45
|
-
"addRouteToEnv({name: '#{route.name}', path: #{compiled_regex} , reqs: #{reqs.to_json}, replace: function(opts) { return #{js.join('+')}; } });"
|
47
|
+
"addRouteToEnv({name: '#{route.name}', path: #{compiled_regex}, subdomain: #{subdomain_regex} , reqs: #{reqs.to_json}, replace: function(opts) { return #{js.join('+')}; } });"
|
46
48
|
end
|
47
49
|
end.join("\n");
|
48
50
|
end
|