Use instance variable in paginate_array example from #515
https://github.com/amatsuda/kaminari/pull/515#issuecomment-35795767
This commit is contained in:
parent
769ae4910d
commit
377861df00
|
@ -241,10 +241,12 @@ Kaminari includes a handy template generator.
|
|||
Kaminari provides an Array wrapper class that adapts a generic Array object to the <tt>paginate</tt> view helper.
|
||||
However, the <tt>paginate</tt> helper doesn't automatically handle your Array object (this is intentional and by design).
|
||||
<tt>Kaminari::paginate_array</tt> method converts your Array object into a paginatable Array that accepts <tt>page</tt> method.
|
||||
paginatable_array = Kaminari.paginate_array(my_array_object).page(params[:page]).per(10)
|
||||
|
||||
@paginatable_array = Kaminari.paginate_array(my_array_object).page(params[:page]).per(10)
|
||||
|
||||
You can specify the +total_count+ value through options Hash. This would be helpful when handling an Array-ish object that has a different +count+ value from actual +count+ such as RSolr search result or when you need to generate a custom pagination. For example:
|
||||
paginatable_array = Kaminari.paginate_array([], total_count: 145).page(params[:page]).per(10)
|
||||
|
||||
@paginatable_array = Kaminari.paginate_array([], total_count: 145).page(params[:page]).per(10)
|
||||
|
||||
== Creating friendly URLs and caching
|
||||
|
||||
|
|
Loading…
Reference in New Issue