@@ -56,7 +56,7 class Project < ActiveRecord::Base | |||||
56 | :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}", |
|
56 | :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}", | |
57 | :association_foreign_key => 'custom_field_id' |
|
57 | :association_foreign_key => 'custom_field_id' | |
58 |
|
58 | |||
59 |
acts_as_nested_set :order |
|
59 | acts_as_nested_set :order => 'name', :dependent => :destroy | |
60 | acts_as_attachable :view_permission => :view_files, |
|
60 | acts_as_attachable :view_permission => :view_files, | |
61 | :delete_permission => :manage_files |
|
61 | :delete_permission => :manage_files | |
62 |
|
62 |
@@ -198,16 +198,17 module CollectiveIdea #:nodoc: | |||||
198 | # set left |
|
198 | # set left | |
199 | node[left_column_name] = indices[scope.call(node)] += 1 |
|
199 | node[left_column_name] = indices[scope.call(node)] += 1 | |
200 | # find |
|
200 | # find | |
201 | where(["#{quoted_parent_column_full_name} = ? #{scope.call(node)}", node]).order("#{quoted_left_column_full_name}, #{quoted_right_column_full_name}, id").each{|n| set_left_and_rights.call(n) } |
|
201 | where(["#{quoted_parent_column_name} = ? #{scope.call(node)}", node]). | |
|
202 | order(acts_as_nested_set_options[:order]). | |||
|
203 | each{|n| set_left_and_rights.call(n) } | |||
202 | # set right |
|
204 | # set right | |
203 | node[right_column_name] = indices[scope.call(node)] += 1 |
|
205 | node[right_column_name] = indices[scope.call(node)] += 1 | |
204 | node.save!(:validate => validate_nodes) |
|
206 | node.save!(:validate => validate_nodes) | |
205 | end |
|
207 | end | |
206 |
|
208 | |||
207 | # Find root node(s) |
|
209 | # Find root node(s) | |
208 |
root_nodes = where("#{quoted_parent_column_ |
|
210 | root_nodes = where("#{quoted_parent_column_name} IS NULL"). | |
209 |
|
|
211 | order(acts_as_nested_set_options[:order]).each do |root_node| | |
210 | each do |root_node| |
|
|||
211 | # setup index for this scope |
|
212 | # setup index for this scope | |
212 | indices[scope.call(root_node)] ||= 0 |
|
213 | indices[scope.call(root_node)] ||= 0 | |
213 | set_left_and_rights.call(root_node) |
|
214 | set_left_and_rights.call(root_node) |
General Comments 0
You need to be logged in to leave comments.
Login now