acts_as_many_trees 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/acts_as_many_trees/base.rb +4 -3
- data/lib/acts_as_many_trees/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c3bfefc3282fed57798445fa23373f998a246c1
|
4
|
+
data.tar.gz: 4e7b8ad53c46b55f2420b9f2707219beb576ed21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62d7bdf039c5f403736e468115dc81c3f442203e76933c589d8f00eb0881b3cc8b7b1f0d2bea14b9177879e1b25cd549d82f9a855823eefa98fd173befe94fc3
|
7
|
+
data.tar.gz: 47540542e382c7afcf35a0229e71170000d79a5b9c595246c474931a8708af0b60e2a9fa4f9d69d63ef0104b9d008915abb42bb75d0b71c1ee0dca683baedfad
|
@@ -30,14 +30,14 @@ module ActsAsManyTrees
|
|
30
30
|
extend ActiveSupport::Concern
|
31
31
|
included do
|
32
32
|
has_many :unscoped_descendant_links,
|
33
|
-
->{order(:position)},
|
33
|
+
# ->{order(:position)},
|
34
34
|
class_name: hierarchy_class.to_s,
|
35
35
|
foreign_key: 'ancestor_id',
|
36
36
|
dependent: :delete_all,
|
37
37
|
inverse_of: :unscoped_ancestor
|
38
38
|
|
39
39
|
has_many :unscoped_ancestor_links,
|
40
|
-
|
40
|
+
->{order(:position)},
|
41
41
|
class_name: hierarchy_class.to_s,
|
42
42
|
foreign_key: 'descendant_id',
|
43
43
|
dependent: :delete_all,
|
@@ -76,6 +76,7 @@ module ActsAsManyTrees
|
|
76
76
|
joins(inner_join).joins(outer_join).merge(where(Arel::Nodes::Equality.new(h2[:ancestor_id],nil)))
|
77
77
|
}
|
78
78
|
scope :not_this,->(this_id) { where.not(id: this_id)}
|
79
|
+
scope :ordered,->{order("#{hierarchy_table_name}.position")}
|
79
80
|
end
|
80
81
|
delegate :hierarchy_class, to: :class
|
81
82
|
#can be over-ridden in the instance
|
@@ -92,7 +93,7 @@ module ActsAsManyTrees
|
|
92
93
|
existing_tree_name = inpt_parent[:existing_tree_name] || self.default_tree_name
|
93
94
|
else
|
94
95
|
new_parent=inpt_parent
|
95
|
-
after_node=inpt_parent.children.last unless inpt_parent.nil?
|
96
|
+
after_node=inpt_parent.children.ordered.last unless inpt_parent.nil?
|
96
97
|
before_node=inpt_parent.next_sibling unless inpt_parent.nil?
|
97
98
|
tree_name = inpt_parent ? inpt_parent.default_tree_name : self.default_tree_name
|
98
99
|
existing_tree_name = self.default_tree_name
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_many_trees
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Small
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|