From 8cc5847aec8310648c57d8d51a4e85409d0ae797 Mon Sep 17 00:00:00 2001
From: Steffen van Bergerem <svbergerem@online.de>
Date: Sat, 11 Oct 2014 22:21:31 +0200
Subject: [PATCH] Paginate contacts

---
 app/controllers/contacts_controller.rb | 2 +-
 app/views/contacts/index.html.haml     | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb
index 462bc1692c..9a57ba3e43 100644
--- a/app/controllers/contacts_controller.rb
+++ b/app/controllers/contacts_controller.rb
@@ -65,7 +65,7 @@ class ContactsController < ApplicationController
       relation.includes(:person => :profile).to_a.tap {|contacts|
         contacts.sort_by! {|contact| contact.person.name }
       }
-    }.inject(:+)
+    }.inject(:+).paginate(:page => params[:page], :per_page => 25)
   end
 
   def set_up_contacts_mobile
diff --git a/app/views/contacts/index.html.haml b/app/views/contacts/index.html.haml
index 6bf43a5131..4d8f223b4f 100644
--- a/app/views/contacts/index.html.haml
+++ b/app/views/contacts/index.html.haml
@@ -11,8 +11,8 @@
         = render 'contacts/header'
 
         - if @contacts_size > 0
-          - @contacts.each do |contact|
-            = render 'contacts/contact', :contact => contact
+          = render @contacts
+          = will_paginate @contacts
         - else
           .no_contacts
             %h3
-- 
GitLab