Skip to content

Commit

Permalink
count number of siblings by #count, not #size (not everywhere)
Browse files Browse the repository at this point in the history
  • Loading branch information
khustochka committed Jan 23, 2010
1 parent 957e287 commit e8b478a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/sorted_hierarchy/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def correctness_of_sort_value
unless raw_value.to_s =~ /\A[+-]?\d+\Z/
errors.add(get_sort_column, :not_a_number, :value => raw_value)
else
latest = (self.top_level? ? self.class.count : self.parent.children.size) + (new_record? ? 1 : 0)
latest = (self.top_level? ? self.class.count : self.parent.children.count) + (new_record? ? 1 : 0)
if self[get_sort_column] > latest
errors.add(get_sort_column, :less_than_or_equal_to, :value => raw_value, :count => latest)
end
Expand All @@ -110,7 +110,7 @@ def correctness_of_sort_value
end

def give_way_to_create
latest = (self.top_level? ? self.class.count : self.parent.children.size) + 1
latest = (self.top_level? ? self.class.count : self.parent.children.count) + 1
self[get_sort_column] ||= latest
if self[get_sort_column] < latest
conditions = ["#{get_sort_column} >= #{self[get_sort_column]}"]
Expand Down

0 comments on commit e8b478a

Please sign in to comment.