Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 44 lines (30 sloc) 0.998 kB
04d793e @richardiux adding initial documentation
authored
1 ## sunspot_with_kaminari
2
5053865 @richardiux sunspot_with_kaminari is no longer needed
authored
3 ### Sunspot now supports kaminari and this gem is no longer necessary
4
5 A basic example on how to paginate with sunspot's buit-in support for kaminari:
6
7 ```ruby
8 # controller
9 @results = Post.search do
10 fulltext "pizza"
11 paginate page: params[:page], per_page: 20
12 end.results
13
14 # views
15 <%= paginate @results, theme: "bootstrap" %>
16 ```
17
04d793e @richardiux adding initial documentation
authored
18 sunspot_with_kaminari extends sunspot to have the required methods for pagination with kaminari.
19
20 ### Installation & Usage
21
9ebe6e9 @richardiux update formatting on documentation
authored
22 on `Gemfile`
04d793e @richardiux adding initial documentation
authored
23
9ebe6e9 @richardiux update formatting on documentation
authored
24 gem 'kaminari'
25 gem "sunspot_rails"
c27f0eb @richardiux Bump version to 0.2
authored
26 gem "sunspot_with_kaminari", '~> 0.2.0'
31b5a4a @richardiux Now it works with latest kaminari, adding documentation on usage
authored
27
28 on the controller
29
30 @products ||= Product.search do
31 keywords params[:search]
32 paginate :page => params[:page], :per_page => 20
33 end
34
35 on the view you want to do something like this:
36
37 <ul>
38 <% @products.results.each do |product| %>
39 <li><%= product.name %></li>
40 <% end %>
41 </ul>
42
5053865 @richardiux sunspot_with_kaminari is no longer needed
authored
43 <%= paginate @products, :window => 1 %>
Something went wrong with that request. Please try again.