awesome_nested_set 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +13 -1
- data/README.md +9 -6
- data/lib/awesome_nested_set/model.rb +13 -2
- data/lib/awesome_nested_set/model/prunable.rb +1 -0
- data/lib/awesome_nested_set/move.rb +3 -3
- data/lib/awesome_nested_set/set_validator.rb +1 -1
- data/lib/awesome_nested_set/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f8c65ecba7e654a2e914de64f646e5e43416e47
|
4
|
+
data.tar.gz: c9d4bda2db60143062026f576080982698fa73ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98ecf4b03fd84f510f84092fe197c73b8a6612dfd80444d9c4dd79d49bdfb3f0ebb4f47966f6ce5e02aadb9006682f1d5fc5cb9c6654682fff286d0585ec1dc1
|
7
|
+
data.tar.gz: efc4897f020894d3798c6c00782baa3de7409d14f02890608da4f8245f4dfc59708ac6771efe2f1667b8b9f324c78fb3705ddee1b7df3b8d403bbdb13298f6ba
|
data/CHANGELOG
CHANGED
@@ -1,9 +1,21 @@
|
|
1
|
+
3.0.2
|
2
|
+
* Fix `dependent: :restrict_with_exception` not allowing a delete to occur. [Brendan Kilfoil]
|
3
|
+
* Replace `Arel::SelectManager#join_sql` with `Arel::SelectManager#join_sources` as `Arel::Node#joins` accepts AST as well. [Swanand Pagnis]
|
4
|
+
* Corrected nested_set_scope usage. [Finbarr Taylor] [#292](https://github.com/collectiveidea/awesome_nested_set/pull/292)
|
5
|
+
* Fix bug: when model with default_scope make #lft and #rgt wrong [eddie](https://github.com/afunction) [#281](https://github.com/collectiveidea/awesome_nested_set/pull/281)
|
6
|
+
* [Compare to 3.0.1](https://github.com/collectiveidea/awesome_nested_set/compare/v3.0.1...v3.0.2)
|
7
|
+
|
8
|
+
3.0.1
|
9
|
+
* Fixed `dependent: :destroy` when called from associated object. #162 [Kuldeep Aggarwal]
|
10
|
+
* [Compare to 3.0.0](https://github.com/collectiveidea/awesome_nested_set/compare/v3.0.0...v3.0.1)
|
11
|
+
|
1
12
|
3.0.0
|
2
13
|
* Support Rails 4.1 [Micah Geisel]
|
3
14
|
* Support dependent: restrict_with_error [Tiago Moraes]
|
4
15
|
* Added information to the README regarding indexes to be added for performance [bdarfler]
|
5
16
|
* Modified associate_parents to add child objects to the parent#children collection [Tiago Moraes]
|
6
|
-
*
|
17
|
+
* Fix `dependent: :restrict_with_exception` not allowing a delete to occur. [Brendan Kilfoil]
|
18
|
+
* [Compare to v2.1.6](https://github.com/collectiveidea/awesome_nested_set/compare/v2.1.6...v3.0.0)
|
7
19
|
|
8
20
|
2.1.6
|
9
21
|
* Fixed rebuild! when there is a default_scope with order [Adrian Serafin]
|
data/README.md
CHANGED
@@ -23,19 +23,22 @@ gem 'awesome_nested_set'
|
|
23
23
|
|
24
24
|
## Usage
|
25
25
|
|
26
|
-
To make use of `awesome_nested_set
|
26
|
+
To make use of `awesome_nested_set` your model needs to have 3 fields:
|
27
27
|
`lft`, `rgt`, and `parent_id`. The names of these fields are configurable.
|
28
|
-
You can also have
|
28
|
+
You can also have optional fields: `depth` and `children_count`. These fields are configurable.
|
29
29
|
|
30
30
|
```ruby
|
31
31
|
class CreateCategories < ActiveRecord::Migration
|
32
32
|
def self.up
|
33
33
|
create_table :categories do |t|
|
34
34
|
t.string :name
|
35
|
-
t.integer :parent_id
|
36
|
-
t.integer :lft
|
37
|
-
t.integer :rgt
|
38
|
-
|
35
|
+
t.integer :parent_id, :null => true, :index => true
|
36
|
+
t.integer :lft, :null => false, :index => true
|
37
|
+
t.integer :rgt, :null => false, :index => true
|
38
|
+
|
39
|
+
# optional fields
|
40
|
+
t.integer :depth, :null => false
|
41
|
+
t.integer :children_count, :null => false
|
39
42
|
end
|
40
43
|
end
|
41
44
|
|
@@ -145,7 +145,18 @@ module CollectiveIdea #:nodoc:
|
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
|
-
self.class.base_class.nested_set_scope options
|
148
|
+
self.class.base_class.unscoped.nested_set_scope options
|
149
|
+
end
|
150
|
+
|
151
|
+
# Separate an other `nested_set_scope` for unscoped model
|
152
|
+
# because normal query still need activerecord `default_scope`
|
153
|
+
# Only activerecord callbacks need unscoped model to handle the nested set records
|
154
|
+
# And class level `nested_set_scope` seems just for query `root` `child` .. etc
|
155
|
+
# I think we don't have to provide unscoped `nested_set_scope` in class level.
|
156
|
+
def nested_set_scope_without_default_scope(*args)
|
157
|
+
self.class.unscoped do
|
158
|
+
nested_set_scope(*args)
|
159
|
+
end
|
149
160
|
end
|
150
161
|
|
151
162
|
def to_text
|
@@ -171,7 +182,7 @@ module CollectiveIdea #:nodoc:
|
|
171
182
|
end
|
172
183
|
|
173
184
|
def right_most_node
|
174
|
-
@right_most_node ||=
|
185
|
+
@right_most_node ||= nested_set_scope(
|
175
186
|
:order => "#{quoted_right_column_full_name} desc"
|
176
187
|
).first
|
177
188
|
end
|
@@ -43,6 +43,7 @@ module CollectiveIdea #:nodoc:
|
|
43
43
|
end
|
44
44
|
elsif acts_as_nested_set_options[:dependent] == :restrict_with_exception
|
45
45
|
raise ActiveRecord::DeleteRestrictionError.new(:children) unless leaf?
|
46
|
+
return true
|
46
47
|
elsif acts_as_nested_set_options[:dependent] == :restrict_with_error
|
47
48
|
unless leaf?
|
48
49
|
record = self.class.human_attribute_name(:children).downcase
|
@@ -24,7 +24,7 @@ module CollectiveIdea #:nodoc:
|
|
24
24
|
|
25
25
|
lock_nodes_between! a, d
|
26
26
|
|
27
|
-
|
27
|
+
nested_set_scope_without_default_scope.where(where_statement(a, d)).update_all(
|
28
28
|
conditions(a, b, c, d)
|
29
29
|
)
|
30
30
|
end
|
@@ -33,7 +33,7 @@ module CollectiveIdea #:nodoc:
|
|
33
33
|
|
34
34
|
delegate :left, :right, :left_column_name, :right_column_name,
|
35
35
|
:quoted_left_column_name, :quoted_right_column_name,
|
36
|
-
:quoted_parent_column_name, :parent_column_name, :
|
36
|
+
:quoted_parent_column_name, :parent_column_name, :nested_set_scope_without_default_scope,
|
37
37
|
:primary_column_name, :quoted_primary_column_name, :primary_id,
|
38
38
|
:to => :instance
|
39
39
|
|
@@ -121,7 +121,7 @@ module CollectiveIdea #:nodoc:
|
|
121
121
|
when :child then right(target)
|
122
122
|
when :left then left(target)
|
123
123
|
when :right then right(target) + 1
|
124
|
-
when :root then
|
124
|
+
when :root then nested_set_scope_without_default_scope.pluck(right_column_name).max + 1
|
125
125
|
else raise ActiveRecord::ActiveRecordError, "Position should be :child, :left, :right or :root ('#{position}' received)."
|
126
126
|
end
|
127
127
|
end
|
@@ -29,7 +29,7 @@ module CollectiveIdea #:nodoc:
|
|
29
29
|
|
30
30
|
def join_scope
|
31
31
|
join_arel = arel_table.join(parent, Arel::Nodes::OuterJoin).on(parent[primary_column_name].eq(arel_table[parent_column_name]))
|
32
|
-
self.scope = scope.joins(join_arel.
|
32
|
+
self.scope = scope.joins(join_arel.join_sources)
|
33
33
|
end
|
34
34
|
|
35
35
|
def filter_scope
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awesome_nested_set
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Keepers
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2015-01-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -138,8 +138,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
140
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.
|
141
|
+
rubygems_version: 2.4.5
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: An awesome nested set implementation for Active Record
|
145
145
|
test_files: []
|
146
|
+
has_rdoc:
|