auto_breadcrumbs 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/auto_breadcrumbs/controller.rb +14 -12
- data/lib/auto_breadcrumbs/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b25c6416df01b8c1893082a7fdd50a79f1b97f6e
|
4
|
+
data.tar.gz: 5ea2e2a03603fecf4a1a432268c718dc52a4a1f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a267e25a24b773f93e0a74f2f3f455c22a58fb0ff3573cbca8cdaa9ab9882c300e96dfbe98f35a323f40447327ccb71520f385ef96e6cd8e26d0100c150e8978
|
7
|
+
data.tar.gz: 532e84006f150710d765b5a3ba57649ed266a6fe7e9dfcc4aa2bee8ef0a25a295d2bc4c8c8354263b637c3e6523d93708ae7a9aac441577df222cc6edc441f91
|
@@ -20,33 +20,35 @@ module AutoBreadcrumbs
|
|
20
20
|
# nested resources
|
21
21
|
Rails.application.routes.router.recognize(request) do |route, matches, param|
|
22
22
|
route.required_parts[0...-1].each do |required_part|
|
23
|
-
resources_name
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
resources_name = required_part.to_s.gsub('_id', '').pluralize
|
24
|
+
resource_index_path = index_path(resources_name)
|
25
|
+
nested_resource_translation = resource_translation(resources_name)
|
26
|
+
nested_action_translation = action_translation(resources_name, 'show')
|
27
27
|
|
28
|
-
add_breadcrumb(
|
29
|
-
add_breadcrumb(
|
28
|
+
add_breadcrumb(nested_resource_translation, resource_index_path) if nested_resource_translation
|
29
|
+
add_breadcrumb(nested_action_translation) if nested_action_translation
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
resource_index_path = index_path(params[:controller])
|
35
|
-
action_translation = action_translation(params[:controller], params[:action])
|
36
|
-
|
33
|
+
resource_index_path = index_path(params[:controller])
|
37
34
|
add_breadcrumb(resource_translation, resource_index_path) if resource_translation
|
38
35
|
add_breadcrumb(action_translation) if action_translation
|
39
36
|
end
|
40
37
|
end
|
41
38
|
|
42
|
-
def resource_translation(resources_name)
|
39
|
+
def resource_translation(resources_name = nil)
|
40
|
+
resources_name ||= params[:controller]
|
41
|
+
|
43
42
|
if index_path(resources_name)
|
44
43
|
breadcrumbs_t("controllers.#{ resources_name }.index") ||
|
45
44
|
resources_name.humanize
|
46
45
|
end
|
47
46
|
end
|
48
47
|
|
49
|
-
def action_translation(resources_name, action_name)
|
48
|
+
def action_translation(resources_name = nil, action_name = nil)
|
49
|
+
resources_name ||= params[:controller]
|
50
|
+
action_name ||= params[:action]
|
51
|
+
|
50
52
|
mapped_action_name = breadcrumbs_action_name(action_name)
|
51
53
|
|
52
54
|
unless mapped_action_name == 'index'
|