-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.mb
64 lines (51 loc) · 1.84 KB
/
README.mb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
ELIXIR PAGINATE
===============
This is the plugin for paginating in rails 2.x.
INSTALLATION IN RAILS (2.x)
===========================
The plugin can now be installed from github, which is the easiest way to keep it up to date.
script/plugin install git://github.com/TXANT/elixir_paginate.git
Alternatively you can install it in vendors/plugin. At first, you need too download file from github. And then, place that file under the 'vendors/plugin' of your project.
And then, you must add below codes to controller's functions which you want to use :
```.rb
# パジネーションの為に
@page = params[:page]
# 最初(さいしょ)パージを検証(けんしょう)?
@next = (@page == nil ? 2 : (@page.to_i+1))
# rows par page
@par_page = 5
@count = @books.length
@var = ElixirPaginate.paginate(@page, @count, @par_page)
At the view page, you need to add below codes. Put your controller at the place of 'your_controller' :
```.erb
<!-- link the stylesheet -->
<%= stylesheet_link_tag 'pagination' %>
<!-- to show the page numbers -->
<div class="pagination">
<!-- パージ番号を表示 -->
<ul>
<% if @next > 2 %>
<li>
<%= link_to '<<', :controller => 'book', :page => @next-2, :author => params[:author] %>
</li>
<% end %>
<% for i in 1..@var[0] %>
<li>
<%= link_to i, :controller => 'book', :page => i, :author => params[:author] %><% end %>
</li>
<% end %>
<% if @next < @var[0]+1 %>
<li>
<%= link_to '>>', :controller => 'book', :page => @next, :author => params[:author] %>
</li>
<% end %>
</ul>
</div>
<!-- To show the list -->
<% @your_identifier[@var[1],@par_page].each do |f| %>
<!--
your codes here
-->
<% end %>
```
Copyright (c) 2013 Thant Shwe Aung, released under the MIT license