Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding pagination to updates using kaminari

  • Loading branch information...
commit 66294928814c30654679784c353c546ec98fac3d 1 parent 3e8f6d3
@zr2d2 zr2d2 authored
View
3  Gemfile
@@ -27,3 +27,6 @@ gem 'jammit'
# Use RedCloth to format text
gem 'RedCloth'
+
+# Use kaminari for pagination
+gem 'kaminari'
View
5 Gemfile.lock
@@ -57,11 +57,13 @@ GEM
i18n (0.5.0)
jammit (0.6.3)
yui-compressor (>= 0.9.3)
- mail (2.2.19)
+ kaminari (0.12.4)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
+ rails (>= 3.0.0)
treetop (~> 1.4.8)
+ mail (2.2.19)
mime-types (1.16)
mysql (2.8.1)
numerizer (0.1.1)
@@ -116,6 +118,7 @@ DEPENDENCIES
devise_cas_authenticatable!
god
jammit
+ kaminari
mysql
rails (= 3.0.10)
rmagick (= 2.12.2)
View
2  app/controllers/updates_controller.rb
@@ -10,7 +10,7 @@ def get_vehicle
# GET /updates
# GET /updates.xml
def index
- @updates = @vehicle.updates
+ @updates = @vehicle.updates.page(params[:page]).per(30)
respond_to do |format|
format.html # index.html.erb
View
2  app/views/updates/index.html.erb
@@ -4,6 +4,7 @@
<br />
<div class="mc-indent">
<h2 id="updates">Updates <%= link_to 'Add', new_vehicle_update_path, :class => "link-button" if can? :create, Update%></h2>
+ <%= paginate @updates %>
<div>
<table cellpadding="0" cellspacing="0" width="100%" class="elements">
<thead>
@@ -20,6 +21,7 @@
</tr>
</thead>
<tbody>
+ <% paginate @updates %>
<% @updates.each do |update| %>
<tr class="<%= cycle('odd', 'even') %>">
<td><%= update.id %></td>
Please sign in to comment.
Something went wrong with that request. Please try again.