Skip to content

Commit

Permalink
tweak to fix ordering bug in certain cases (-20 was being cast as 184…
Browse files Browse the repository at this point in the history
…46744073709551596)
  • Loading branch information
bkoski committed Mar 18, 2011
1 parent 2a4cd33 commit 4a01772
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/slug/slug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def assign_slug_sequence

# Returns the next unique index for a slug.
def next_slug_sequence
last_in_sequence = self.class.where("#{self.slug_column} LIKE ?", self[self.slug_column] + '%').order("CAST(REPLACE(#{self.slug_column},'#{self[self.slug_column]}','') AS UNSIGNED)").first
last_in_sequence = self.class.where("#{self.slug_column} LIKE ?", self[self.slug_column] + '%').order("CAST(REPLACE(#{self.slug_column},'#{self[self.slug_column]}-','') AS UNSIGNED) DESC").first
if last_in_sequence.nil?
return 0
else
Expand Down

0 comments on commit 4a01772

Please sign in to comment.