aunderwo-acts_as_tree 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/acts_as_tree.gemspec +1 -1
- data/lib/active_record/acts/tree.rb +3 -8
- metadata +1 -1
data/acts_as_tree.gemspec
CHANGED
@@ -9,7 +9,7 @@ module ActiveRecord
|
|
9
9
|
# association. This requires that you have a foreign key column, which by default is called +parent_id+.
|
10
10
|
#
|
11
11
|
# class Category < ActiveRecord::Base
|
12
|
-
# acts_as_tree :order => "name"
|
12
|
+
# acts_as_tree :order => "name"
|
13
13
|
# end
|
14
14
|
#
|
15
15
|
# Example:
|
@@ -40,16 +40,11 @@ module ActiveRecord
|
|
40
40
|
# * <tt>order</tt> - makes it possible to sort the children according to this SQL snippet.
|
41
41
|
# * <tt>counter_cache</tt> - keeps a count in a +children_count+ column if set to +true+ (default: +false+).
|
42
42
|
def acts_as_tree(options = {})
|
43
|
-
configuration = { :foreign_key => "parent_id", :order => nil, :counter_cache => nil
|
43
|
+
configuration = { :foreign_key => "parent_id", :order => nil, :counter_cache => nil }
|
44
44
|
configuration.update(options) if options.is_a?(Hash)
|
45
45
|
|
46
|
-
# Added for model Page
|
47
46
|
belongs_to :parent, :class_name => name, :foreign_key => configuration[:foreign_key], :counter_cache => configuration[:counter_cache]
|
48
|
-
|
49
|
-
has_many :children, :class_name => name, :foreign_key => configuration[:foreign_key], :order => configuration[:order]
|
50
|
-
else
|
51
|
-
has_many :children, :class_name => name, :foreign_key => configuration[:foreign_key], :order => configuration[:order], :dependent => configuration[:dependent]
|
52
|
-
end
|
47
|
+
has_many :children, :class_name => name, :foreign_key => configuration[:foreign_key], :order => configuration[:order], :dependent => :destroy
|
53
48
|
|
54
49
|
class_eval <<-EOV
|
55
50
|
include ActiveRecord::Acts::Tree::InstanceMethods
|