Class: Grapple::Components::KaminariPagination
- Inherits:
-
HtmlComponent
- Object
- BaseComponent
- HtmlComponent
- Grapple::Components::KaminariPagination
- Defined in:
- lib/grapple/components/kaminari_pagination.rb
Overview
Generates paging links using will_paginate.
Instance Attribute Summary
Attributes inherited from BaseComponent
#builder, #columns, #params, #records, #template
Instance Method Summary collapse
Methods inherited from BaseComponent
Constructor Details
This class inherits a constructor from Grapple::Components::BaseComponent
Instance Method Details
#render(paginate_parameters = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/grapple/components/kaminari_pagination.rb', line 17 def render(paginate_parameters = {}) td_class = "" if records.instance_of?(Array) html = ' ' elsif !params[:query].blank? and records.empty? html = h(t()) td_class = "class='text-left'" else begin # paginate helper will throw an error if without_count is being used html = template.paginate(records) rescue Exception => e html = template.link_to_prev_page(records, "Previous Page") || "" html += " " if html html += template.link_to_next_page(records, "Next Page") || "" end end builder.row "<td colspan=\"#{num_columns}\" #{td_class}>#{html}</td>" end |