Permalink
Browse files

adding pagination to updates using kaminari

  • Loading branch information...
1 parent 3e8f6d3 commit 66294928814c30654679784c353c546ec98fac3d @zr2d2 zr2d2 committed Sep 17, 2011
Showing with 10 additions and 2 deletions.
  1. +3 −0 Gemfile
  2. +4 −1 Gemfile.lock
  3. +1 −1 app/controllers/updates_controller.rb
  4. +2 −0 app/views/updates/index.html.erb
View
@@ -27,3 +27,6 @@ gem 'jammit'
# Use RedCloth to format text
gem 'RedCloth'
+
+# Use kaminari for pagination
+gem 'kaminari'
View
@@ -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)
@@ -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
@@ -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>

0 comments on commit 6629492

Please sign in to comment.