summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2014-01-20 12:53:01 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2014-01-20 12:53:01 +0000
commit1c0c22de170ebecf9570fe36af0a3fba0ea2b496 (patch)
tree0900b1be5f10b46293b04e74992c99b1075249b1
parentbcec29d5e42b6b93d42daa5980293ba252d00b31 (diff)
downloadredmine-1c0c22de170ebecf9570fe36af0a3fba0ea2b496.tar.gz
redmine-1c0c22de170ebecf9570fe36af0a3fba0ea2b496.zip
use :order_column option instead of :order for acts_as_nested_set
git-svn-id: http://svn.redmine.org/redmine/trunk@12680 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/project.rb2
-rw-r--r--lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb9
2 files changed, 5 insertions, 6 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 798e64f69..c4f135bee 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -56,7 +56,7 @@ class Project < ActiveRecord::Base
:join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}",
:association_foreign_key => 'custom_field_id'
- acts_as_nested_set :order => 'name', :dependent => :destroy
+ acts_as_nested_set :order_column => 'name', :dependent => :destroy
acts_as_attachable :view_permission => :view_files,
:delete_permission => :manage_files
diff --git a/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb b/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb
index 1a7ceae15..ff86d7feb 100644
--- a/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb
+++ b/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb
@@ -198,17 +198,16 @@ module CollectiveIdea #:nodoc:
# set left
node[left_column_name] = indices[scope.call(node)] += 1
# find
- where(["#{quoted_parent_column_name} = ? #{scope.call(node)}", node]).
- order(acts_as_nested_set_options[:order]).
- each{|n| set_left_and_rights.call(n) }
+ 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) }
# set right
node[right_column_name] = indices[scope.call(node)] += 1
node.save!(:validate => validate_nodes)
end
# Find root node(s)
- root_nodes = where("#{quoted_parent_column_name} IS NULL").
- order(acts_as_nested_set_options[:order]).each do |root_node|
+ root_nodes = where("#{quoted_parent_column_full_name} IS NULL").
+ order(acts_as_nested_set_options[:order_column]).
+ each do |root_node|
# setup index for this scope
indices[scope.call(root_node)] ||= 0
set_left_and_rights.call(root_node)