diff --git a/lib/friendly_id/active_record_adapter/tasks.rb b/lib/friendly_id/active_record_adapter/tasks.rb
index <HASH>..<HASH> 100644
--- a/lib/friendly_id/active_record_adapter/tasks.rb
+++ b/lib/friendly_id/active_record_adapter/tasks.rb
@@ -30,7 +30,7 @@ module FriendlyId
         :include => :slug,
         :limit   => (ENV["LIMIT"] || 100).to_i,
         :offset  => 0,
-        :order   => ENV["ORDER"] || "#{klass.table_name}.id ASC",
+        :order   => ENV["ORDER"] || "#{klass.table_name}.#{klass.primary_key} ASC",
       }.merge(task_options || {})
 
       while records = find(:all, options) do
fixed rake task to using class.primary_key rather than string "id"