Permalink
Browse files

Pagenation

  • Loading branch information...
twata701 committed Feb 16, 2014
1 parent 359c78f commit d9728347463491b004bba0c3d038ca7acd5aad9a
View
@@ -45,3 +45,6 @@ end
# Use debugger
# gem 'debugger', group: [:development, :test]
# Pagenation
gem 'kaminari'
View
@@ -47,6 +47,9 @@ GEM
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.1)
kaminari (0.15.1)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
less (2.4.0)
commonjs (~> 0.2.7)
less-rails (2.4.2)
@@ -127,6 +130,7 @@ DEPENDENCIES
coffee-rails (~> 4.0.0)
jbuilder (~> 1.2)
jquery-rails
kaminari
less-rails
rails (= 4.0.0)
sass-rails (~> 4.0.0)
@@ -6,7 +6,7 @@ class TweetsController < ApplicationController
# GET /tweets
# GET /tweets.json
def index
@tweets = Tweet.all
@tweets = Tweet.order(:id).page params[:page]
end
# GET /tweets/1
@@ -0,0 +1,3 @@
<li>
<%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote %>
</li>
@@ -0,0 +1,3 @@
<li class="disabled">
<%= link_to raw(t 'views.pagination.truncate'), '#' %>
</li>
@@ -0,0 +1,3 @@
<li>
<%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {:remote => remote} %>
</li>
@@ -0,0 +1,3 @@
<li>
<%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote %>
</li>
@@ -0,0 +1,3 @@
<li class="<%= 'active' if page.current? %>">
<%= link_to page, page.current? ? '#' : url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
</li>
@@ -0,0 +1,17 @@
<%= paginator.render do -%>
<div class="pagination">
<ul>
<%= first_page_tag unless current_page.first? %>
<%= prev_page_tag unless current_page.first? %>
<% each_page do |page| -%>
<% if page.left_outer? || page.right_outer? || page.inside_window? -%>
<%= page_tag page %>
<% elsif !page.was_truncated? -%>
<%= gap_tag %>
<% end -%>
<% end -%>
<%= next_page_tag unless current_page.last? %>
<%= last_page_tag unless current_page.last? %>
</ul>
</div>
<% end -%>
@@ -0,0 +1,3 @@
<li>
<%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote %>
</li>
@@ -40,6 +40,4 @@
</tbody>
</table>
<br>
<%= link_to 'New Tweet', new_tweet_path %>
<%= paginate (@tweets) %>
@@ -0,0 +1,10 @@
Kaminari.configure do |config|
# config.default_per_page = 100
# config.max_per_page = nil
# config.window = 4
# config.outer_window = 0
# config.left = 0
# config.right = 0
# config.page_method_name = :page
# config.param_name = :page
end

0 comments on commit d972834

Please sign in to comment.