added pagination to User#show
This commit is contained in:
parent
cc87061fe2
commit
293837984e
|
@ -2,6 +2,10 @@ class UserController < ApplicationController
|
||||||
def show
|
def show
|
||||||
@user = User.find_by_screen_name!(params[:username])
|
@user = User.find_by_screen_name!(params[:username])
|
||||||
@answers = @user.answers.reverse_order.paginate(page: params[:page])
|
@answers = @user.answers.reverse_order.paginate(page: params[:page])
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.js
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
#pagination= will_paginate @timeline, renderer: BootstrapPagination::Rails, page_links: false
|
#pagination= will_paginate @timeline, renderer: BootstrapPagination::Rails, page_links: false
|
||||||
|
|
||||||
- if @timeline.next_page
|
- if @timeline.next_page
|
||||||
%button#load-more-btn.btn.btn-default{type: :button, 'data-current-page' => @timeline.current_page, 'data-type' => 'timeline'}
|
%button#load-more-btn.btn.btn-default{type: :button, 'data-current-page' => @timeline.current_page}
|
||||||
Load more
|
Load more
|
||||||
.visible-xs= render 'shared/links'
|
.visible-xs= render 'shared/links'
|
||||||
- else
|
- else
|
||||||
|
|
|
@ -43,6 +43,13 @@
|
||||||
.hidden-xs= render 'shared/links'
|
.hidden-xs= render 'shared/links'
|
||||||
.col-md-9.col-xs-12.col-sm-9
|
.col-md-9.col-xs-12.col-sm-9
|
||||||
= render 'shared/questionbox'
|
= render 'shared/questionbox'
|
||||||
- @answers.each do |a|
|
#answers
|
||||||
= render 'shared/answerbox', a: a
|
- @answers.each do |a|
|
||||||
|
= render 'shared/answerbox', a: a
|
||||||
|
|
||||||
|
#pagination= will_paginate @answers, renderer: BootstrapPagination::Rails, page_links: false
|
||||||
|
|
||||||
|
- if @answers.next_page
|
||||||
|
%button#load-more-btn.btn.btn-default{type: :button, 'data-current-page' => @answers.current_page}
|
||||||
|
Load more
|
||||||
.visible-xs= render 'shared/links'
|
.visible-xs= render 'shared/links'
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
$('#answers').append('<% @answers.each do |a|
|
||||||
|
%><%= j render 'shared/answerbox', a: a
|
||||||
|
%><% end %>');
|
||||||
|
<% if @answers.next_page %>
|
||||||
|
$('#pagination').html('<%= j will_paginate @answers, renderer: BootstrapPagination::Rails, page_links: false %>');
|
||||||
|
<% else %>
|
||||||
|
$('#pagination, #load-more-btn').remove();
|
||||||
|
<% end %>
|
Loading…
Reference in New Issue