Permalink
Browse files

Added pagination with kaminari

  • Loading branch information...
1 parent c6f8937 commit 71c5c9e8cf80d81c2335d9cc809af0c8210c84c4 @rondy committed Dec 5, 2011
View
@@ -10,6 +10,7 @@ gem "carrierwave"
gem "rmagick"
gem "simple_form"
gem "responders"
+gem "kaminari"
group :assets do
gem 'sass-rails', '~> 3.1.5.rc.2'
View
@@ -73,6 +73,8 @@ GEM
thor (~> 0.14)
json (1.6.1)
json_pure (1.6.1)
+ kaminari (0.12.4)
+ rails (>= 3.0.0)
launchy (2.0.5)
addressable (~> 2.2.6)
mail (2.3.0)
@@ -176,6 +178,7 @@ DEPENDENCIES
guard-rspec
hirb
jquery-rails
+ kaminari
launchy
rails (= 3.1.2.rc2)
rb-fsevent
@@ -115,4 +115,8 @@ p.empty {
margin: 1.5em;
padding: 1em;
background-color: #f4feed;
+}
+
+.pagination {
+ text-align: center;
}
@@ -4,7 +4,8 @@ def index
@public_todo_lists = TodoList.
public_visibility.
except_for_user(current_user).
- includes(:tasks, :user, :watchers)
+ includes(:tasks, :user, :watchers).
+ page(params[:page])
respond_with(@public_todo_lists)
end
@@ -3,7 +3,7 @@ class TodoListsController < ApplicationController
before_filter :authenticate_user!
def index
- @todo_lists = current_user.todo_lists.includes(:tasks, :user)
+ @todo_lists = current_user.todo_lists.includes(:tasks, :user).page(params[:page])
respond_with(@todo_lists)
end
@@ -1,7 +1,7 @@
class WatchedListsController < PublicTodoListsController
def index
- @watched_lists = current_user.watched_lists.includes(:tasks, :user, :watchers)
+ @watched_lists = current_user.watched_lists.includes(:tasks, :user, :watchers).page(params[:page])
respond_with(@watched_lists)
end
@@ -7,6 +7,8 @@ class TodoList < ActiveRecord::Base
default_scope order("created_at DESC")
+ paginates_per 5
+
validates :name, :presence => true
accepts_nested_attributes_for :tasks, :reject_if => lambda { |task| task["name"].blank? }, :allow_destroy => true
@@ -9,3 +9,5 @@
</p>
<% end %>
</div>
+
+<%= paginate @public_todo_lists %>
@@ -9,3 +9,5 @@
</p>
<% end %>
</div>
+
+<%= paginate @todo_lists %>
@@ -8,4 +8,6 @@
You aren't watching any public list. Let's <%= link_to "find some", public_todo_lists_path %> for you!
</p>
<% end %>
-</div>
+</div>
+
+<%= paginate @watched_lists %>

0 comments on commit 71c5c9e

Please sign in to comment.