I wanted to add some pagination to my rails project.
I've already added Kaminari
and I've managed to display only 10 records per page. But I'm already missing the next/prev arrow and the page indicator.
I'm using Kaminari.paginate_array(@array).page(params[:page]).per(10)
This is the only thing I've added until now.
I don't know if it's important, but in my view I have @array.to_json
What should I add to display the arrows?
View code:
<% content_for :create_button do %>
<%= create_button(new_battery_reset_path) %>
<% end %>
<div class="tab-content">
<%= paginate @battery_resets %>
<div class="tab-pane active" id="battery-resets" role="tabpanel"
data-battery-resets='<%= @battery_resets.to_json %>'>
</div>
<div class="tab-pane" id="profile" role="tabpanel">...</div>
<div class="tab-pane" id="messages" role="tabpanel">...</div>
</div>
controller code:
def index
@battery_resets = Kaminari.paginate_array(BatteryResetDecorator.build_collection(
::Filters::BatteryReset.new(
current_account.battery_resets.includes({ device: :account },
:device_inspection)
).apply(permited_params[:q])
)).page(params[:page]).per(10)
respond_with(@battery_resets)
end