rails 3,Kaminari pagination for an simple Array -
for paginating common array got solution,
@arr_name = kaminari.paginate_array(@arr_name).page(params[:page]).per(per_page_records)
per_page_records
variable value per needed pagination.
any better ideas??
also have ajax call using pagination 1 can use this,
in view,
give id div tab
div id="paginate"
and inside
<%= paginate @arr_name, :remote => true %>
and in js response file put,
$('#paginate').html('<%= escape_javascript(paginate(@arr_name, :remote => true).to_s) %>');
so requests ajax.
thanks.
this available helper method paginate array object using kaminari. alternative is, suggested solution in kaminari wiki page, add instance methods array object.
if trying common solution based on activemodel return type ( .all returns array , .where returns arl) following workaround.
unless @arr_name.kind_of?(array) @arr_name = @arr_name.page(params[:page]).per(per_page_records) else @arr_name = kaminari.paginate_array(@arr_name).page(params[:page]).per(per_page_records) end
Comments
Post a Comment