simple_nested_set 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -70,7 +70,7 @@ module SimpleNestedSet
70
70
  path = (
71
71
  SELECT GROUP_CONCAT(slug, '/')
72
72
  FROM #{table_name} as l
73
- WHERE l.lft <= #{table_name}.lft AND l.rgt >= #{table_name}.rgt AND parent_id IS NOT NULL
73
+ WHERE l.lft <= #{table_name}.lft AND l.rgt >= #{table_name}.rgt
74
74
  )
75
75
  sql
76
76
  end
@@ -28,7 +28,7 @@ module SimpleNestedSet
28
28
  @node = args.first if args.size == 1
29
29
  @where_values = self.class.scope(node).instance_variable_get(:@where_values) if node
30
30
  end
31
-
31
+
32
32
  def save!
33
33
  attributes = node.instance_variable_get(:@_nested_set_attributes)
34
34
  node.instance_variable_set(:@_nested_set_attributes, nil)
@@ -42,7 +42,11 @@ module SimpleNestedSet
42
42
 
43
43
  # reload left, right, and parent
44
44
  def reload
45
- node.reload(:select => 'lft, rgt, parent_id') unless node.new_record?
45
+ node.reload(:select => attribute_names.join(', ')) unless node.new_record? # FIXME reloading doesn't seem to work?
46
+ end
47
+
48
+ def attribute_names
49
+ @attribute_names ||= node.attribute_names.select { |attribute| ATTRIBUTES.include?(attribute.to_sym) }
46
50
  end
47
51
 
48
52
  def populate_associations(nodes)
@@ -1,3 +1,3 @@
1
1
  module SimpleNestedSet
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -2,7 +2,7 @@ require 'active_record'
2
2
  require 'core_ext/hash/extract_nested_set_attributes'
3
3
 
4
4
  module SimpleNestedSet
5
- ATTRIBUTES = [:parent, :parent_id, :left_id, :right_id]
5
+ ATTRIBUTES = [:parent, :parent_id, :left_id, :right_id, :lft, :rgt, :level, :path]
6
6
 
7
7
  autoload :ActMacro, 'simple_nested_set/act_macro'
8
8
  autoload :ClassMethods, 'simple_nested_set/class_methods'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_nested_set
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sven Fuchs