inferred_crumpets 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/inferred_crumpets/builder.rb +12 -9
- data/lib/inferred_crumpets/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: c254e2775250e0edbe1538b9755690418d5d9981
|
4
|
+
data.tar.gz: 960e259aa006dcdd54b8e2320f11ef7a66f9c049
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f543722bafb28f88c22ce2420bf3867c6ce3669de38f31085359d002e736f2ce9b4f5caa0b389b5aab3ffd1e5c3121cb147d30d94e35ded67d1dbce63abcf94
|
7
|
+
data.tar.gz: ef13a3f10da1567e1950a584c8eb7363479f6d1dfe0ee13644067534069c9d34d91ae6dc9ea6a7d9621fc344b03b772bea87d2d35d834070010cf0d70aa46334
|
@@ -5,7 +5,7 @@ module InferredCrumpets
|
|
5
5
|
def self.build_inferred_crumbs!(view_context)
|
6
6
|
subject = view_context.current_object rescue view_context.collection rescue nil
|
7
7
|
return unless subject
|
8
|
-
parents = [view_context.parent_object].compact
|
8
|
+
parents = [view_context.parent_object].compact rescue []
|
9
9
|
build_all!(view_context, subject, parents)
|
10
10
|
end
|
11
11
|
|
@@ -42,21 +42,24 @@ module InferredCrumpets
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def build_crumb_for_collection!
|
45
|
-
if
|
45
|
+
if subject.is_a?(ActiveRecord::Relation)
|
46
46
|
view_context.crumbs.add_crumb subject_name.pluralize.titleize
|
47
|
-
|
47
|
+
elsif subject.is_a?(ActiveRecord::Base)
|
48
48
|
view_context.crumbs.add_crumb subject.class.table_name.titleize, url_for_collection
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
def build_crumb_for_action!
|
53
|
+
return unless subject.is_a?(ActiveRecord::Base)
|
54
|
+
|
53
55
|
if %w(new create).include?(action)
|
54
|
-
view_context.crumbs.add_crumb
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
view_context.crumbs.add_crumb('New', wrapper_options: { class: 'active' })
|
57
|
+
return
|
58
|
+
end
|
59
|
+
|
60
|
+
build_crumb_for_subject!
|
61
|
+
if %w(edit update).include?(action)
|
62
|
+
view_context.crumbs.add_crumb('Edit', wrapper_options: { class: 'active' })
|
60
63
|
end
|
61
64
|
end
|
62
65
|
|