fixed pagination for real

This commit is contained in:
Georg G 2015-02-12 22:09:11 +01:00
parent e3bc0d6300
commit cb606f942a
3 changed files with 16 additions and 11 deletions

View File

@ -2,6 +2,10 @@ class InboxController < ApplicationController
before_filter :authenticate_user!
def show
@inbox = Inbox.where(user: current_user).order(:created_at).reverse_order
@inbox = Inbox.where(user: current_user).order(:created_at).reverse_order.paginate(page: params[:page])
respond_to do |format|
format.html
format.js
end
end
end

View File

@ -8,15 +8,15 @@
- @inbox.each do |i|
= render 'inbox/entry', i: i
#pagination= will_paginate @inbox, renderer: BootstrapPagination::Rails, page_links: false
- if @inbox.next_page
%button#load-more-btn.btn.btn-default{type: :button, data: { current_page: @inbox.current_page }}
Load more
- if @inbox.empty?
Nothing to see here.
#pagination= will_paginate @inbox, renderer: BootstrapPagination::Rails, page_links: false
- if @inbox.next_page
%button#load-more-btn.btn.btn-default{type: :button, data: { current_page: @inbox.current_page }}
Load more
.col-md-9.col-xs-12.col-sm-9.visible-xs
= render 'inbox/sidebar'

View File

@ -1,8 +1,9 @@
$('#timeline').append('<% @timeline.each do |answer|
%><%= j render 'inbox/entry', a: answer
$('#entries').append('<% @inbox.each do |i|
%><%= j render 'inbox/entry', i: i
%><% end %>');
<% if @timeline.next_page %>
$('#pagination').html('<%= j will_paginate @inbox, renderer: BootstrapPagination::Rails, page_links: false %>');
<% else %>
$('#pagination, #load-more-btn').remove();
<% end %>
<% end %>
<% @inbox.update_all(new: false) %>