Skip to content

Commit a753f07

Browse files
committed
add pagination
1 parent cf2a64b commit a753f07

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ gem 'simple_form'
88
gem "paperclip", "~> 3.0"
99
gem 'aws-sdk'
1010
gem 'faker'
11+
gem 'will_paginate'
12+
gem 'bootstrap-will_paginate'
1113

1214
group :production do
1315
gem 'pg'

Gemfile.lock

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ GEM
3737
bcrypt-ruby (3.1.2)
3838
bootstrap-sass (2.2.2.0)
3939
sass (~> 3.2)
40+
bootstrap-will_paginate (0.0.10)
41+
will_paginate
4042
builder (3.0.4)
4143
climate_control (0.0.3)
4244
activesupport (>= 3.0)
@@ -134,13 +136,15 @@ GEM
134136
uuidtools (2.1.4)
135137
warden (1.2.3)
136138
rack (>= 1.0)
139+
will_paginate (3.0.4)
137140

138141
PLATFORMS
139142
ruby
140143

141144
DEPENDENCIES
142145
aws-sdk
143146
bootstrap-sass (~> 2.2.2.0)
147+
bootstrap-will_paginate
144148
coffee-rails (~> 3.2.1)
145149
devise
146150
faker
@@ -152,3 +156,4 @@ DEPENDENCIES
152156
simple_form
153157
sqlite3
154158
uglifier (>= 1.0.3)
159+
will_paginate

app/controllers/pins_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class PinsController < ApplicationController
44
# GET /pins
55
# GET /pins.json
66
def index
7-
@pins = Pin.order("created_at desc")
7+
@pins = Pin.order("created_at desc").page(params[:page]).per_page(20)
88

99
respond_to do |format|
1010
format.html # index.html.erb

app/views/pins/index.html.erb

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
<div id="pins">
44
<%= render @pins %>
5-
</div>
5+
</div>
6+
7+
<%= will_paginate @pins %>

0 commit comments

Comments
 (0)