From a753f07cfcf443a18d02a7622779ab5aa0d4cf49 Mon Sep 17 00:00:00 2001 From: Robert Ing Date: Mon, 16 Sep 2013 20:47:08 -0700 Subject: [PATCH] add pagination --- Gemfile | 2 ++ Gemfile.lock | 5 +++++ app/controllers/pins_controller.rb | 2 +- app/views/pins/index.html.erb | 4 +++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 3255af4..7d20def 100755 --- a/Gemfile +++ b/Gemfile @@ -8,6 +8,8 @@ gem 'simple_form' gem "paperclip", "~> 3.0" gem 'aws-sdk' gem 'faker' +gem 'will_paginate' +gem 'bootstrap-will_paginate' group :production do gem 'pg' diff --git a/Gemfile.lock b/Gemfile.lock index 81070c6..72d602c 100755 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -37,6 +37,8 @@ GEM bcrypt-ruby (3.1.2) bootstrap-sass (2.2.2.0) sass (~> 3.2) + bootstrap-will_paginate (0.0.10) + will_paginate builder (3.0.4) climate_control (0.0.3) activesupport (>= 3.0) @@ -134,6 +136,7 @@ GEM uuidtools (2.1.4) warden (1.2.3) rack (>= 1.0) + will_paginate (3.0.4) PLATFORMS ruby @@ -141,6 +144,7 @@ PLATFORMS DEPENDENCIES aws-sdk bootstrap-sass (~> 2.2.2.0) + bootstrap-will_paginate coffee-rails (~> 3.2.1) devise faker @@ -152,3 +156,4 @@ DEPENDENCIES simple_form sqlite3 uglifier (>= 1.0.3) + will_paginate diff --git a/app/controllers/pins_controller.rb b/app/controllers/pins_controller.rb index 132cb48..3daba7c 100755 --- a/app/controllers/pins_controller.rb +++ b/app/controllers/pins_controller.rb @@ -4,7 +4,7 @@ class PinsController < ApplicationController # GET /pins # GET /pins.json def index - @pins = Pin.order("created_at desc") + @pins = Pin.order("created_at desc").page(params[:page]).per_page(20) respond_to do |format| format.html # index.html.erb diff --git a/app/views/pins/index.html.erb b/app/views/pins/index.html.erb index aae05b1..06c2c3e 100755 --- a/app/views/pins/index.html.erb +++ b/app/views/pins/index.html.erb @@ -2,4 +2,6 @@
<%= render @pins %> -
\ No newline at end of file + + +<%= will_paginate @pins %> \ No newline at end of file