diff --git a/lib/will_paginate/collection.rb b/lib/will_paginate/collection.rb
index 720c722ae..c4e11ce9b 100644
--- a/lib/will_paginate/collection.rb
+++ b/lib/will_paginate/collection.rb
@@ -13,7 +13,7 @@ module WillPaginate
   # This module provides few of these methods.
   module CollectionMethods
     def total_pages
-      total_entries.zero? ? 1 : (total_entries / per_page.to_f).ceil
+      total_entries.zero? || per_page.zero? ? 1 : (total_entries / per_page.to_f).ceil
     end
 
     # current_page - 1 or nil if there is no previous page
diff --git a/spec/collection_spec.rb b/spec/collection_spec.rb
index d561e8376..f855a9362 100644
--- a/spec/collection_spec.rb
+++ b/spec/collection_spec.rb
@@ -71,6 +71,13 @@
     end
   end
 
+  describe "num_page is zero" do
+    it "should have total_pages 1 when num_page is zero" do
+      collection = create(1,0,1)
+      collection.total_pages.should == 1
+    end
+  end
+
   describe "out of bounds" do
     it "is out of bounds when page number is too high" do
       create(2, 3, 2).should be_out_of_bounds