Permalink
Browse files

Merge remote branch 'origin/master'

  • Loading branch information...
2 parents 90c4a10 + 853e453 commit ad26f7bc21278352ab28bce08bc0f4ac80db3c02 @stefankroes committed Nov 9, 2009
Showing with 12 additions and 10 deletions.
  1. +3 −1 README.rdoc
  2. +2 −2 ancestry.gemspec
  3. +7 −7 lib/ancestry/acts_as_tree.rb
View
@@ -218,8 +218,10 @@ The materialised path pattern requires Ancestry to use a 'like' condition in ord
= Version history
-The latest and recommended version of ancestry is 1.1.3. The three numbers of each version numbers are respectively the major, minor and patch versions. We started with major version 1 because it looks so much better and ancestry was already quite mature and complete when it was published. The major version is only bumped when backwards compatibility is broken. The minor version is bumped when new features are added. The patch version is bumped when bugs are fixed.
+The latest and recommended version of ancestry is 1.1.4. The three numbers of each version numbers are respectively the major, minor and patch versions. We started with major version 1 because it looks so much better and ancestry was already quite mature and complete when it was published. The major version is only bumped when backwards compatibility is broken. The minor version is bumped when new features are added. The patch version is bumped when bugs are fixed.
+- Version 1.1.4 (2009-11-07)
+ - Thanks to a patch from tom taylor, Ancestry now works with different primary keys
- Version 1.1.3 (2009-11-01)
- Fixed a pretty bad bug where several operations took far too many queries
- Version 1.1.2 (2009-10-29)
View
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
s.description = 'Organise ActiveRecord model into a tree structure'
s.summary = 'Ancestry allows the records of a ActiveRecord model to be organised in a tree structure, using a single, intuitively formatted database column. It exposes all the standard tree structure relations (ancestors, parent, root, children, siblings, descendants) and all of them can be fetched in a single sql query. Additional features are named_scopes, integrity checking, integrity restoration, arrangement of (sub)tree into hashes and different strategies for dealing with orphaned records.'
- s.version = '1.1.3'
- s.date = '2009-11-01'
+ s.version = '1.1.4'
+ s.date = '2009-11-07'
s.author = 'Stefan Kroes'
s.email = 's.a.kroes@gmail.com'
@@ -285,7 +285,7 @@ def ancestor_ids
end
def ancestor_conditions
- {:id => ancestor_ids}
+ {self.base_class.primary_key => ancestor_ids}
end
def ancestors depth_options = {}
@@ -297,7 +297,7 @@ def path_ids
end
def path_conditions
- {:id => path_ids}
+ {self.base_class.primary_key => path_ids}
end
def path depth_options = {}
@@ -352,7 +352,7 @@ def children
end
def child_ids
- children.all(:select => :id).map(&:id)
+ children.all(:select => self.base_class.primary_key).map(&self.base_class.primary_key.to_sym)
end
def has_children?
@@ -373,7 +373,7 @@ def siblings
end
def sibling_ids
- siblings.all(:select => :id).collect(&:id)
+ siblings.all(:select => self.base_class.primary_key).collect(&self.base_class.primary_key.to_sym)
end
def has_siblings?
@@ -394,20 +394,20 @@ def descendants depth_options = {}
end
def descendant_ids depth_options = {}
- descendants(depth_options).all(:select => :id).collect(&:id)
+ descendants(depth_options).all(:select => self.base_class.primary_key).collect(&self.base_class.primary_key.to_sym)
end
# Subtree
def subtree_conditions
- ["id = ? or #{self.base_class.ancestry_column} like ? or #{self.base_class.ancestry_column} = ?", self.id, "#{child_ancestry}/%", child_ancestry]
+ ["#{self.base_class.primary_key} = ? or #{self.base_class.ancestry_column} like ? or #{self.base_class.ancestry_column} = ?", self.id, "#{child_ancestry}/%", child_ancestry]
end
def subtree depth_options = {}
self.base_class.ordered_by_ancestry.scope_depth(depth_options, depth).scoped :conditions => subtree_conditions
end
def subtree_ids depth_options = {}
- subtree(depth_options).all(:select => :id).collect(&:id)
+ subtree(depth_options).all(:select => self.base_class.primary_key).collect(&self.base_class.primary_key.to_sym)
end
# Callback disabling

0 comments on commit ad26f7b

Please sign in to comment.