question page added
This commit is contained in:
parent
e483714f44
commit
46c9ccc0ac
|
@ -36,4 +36,10 @@ class UserController < ApplicationController
|
||||||
@type = :friend
|
@type = :friend
|
||||||
render 'show_follow'
|
render 'show_follow'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def questions
|
||||||
|
@title = 'Questions'
|
||||||
|
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first
|
||||||
|
@questions = @user.questions.reverse_order.paginate(page: params[:page])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
.profile--header
|
||||||
|
.container.j2-page
|
||||||
|
.col-md-3.col-xs-12.col-sm-3
|
||||||
|
= render 'user/profile_info'
|
||||||
|
.hidden-xs= render 'shared/links'
|
||||||
|
.col-md-9.col-xs-12.col-sm-9
|
||||||
|
%h1.j2-lh= @title
|
||||||
|
#questions
|
||||||
|
- @questions.each do |a|
|
||||||
|
= render 'shared/answerbox', a: a
|
||||||
|
|
||||||
|
#pagination= will_paginate @questions, renderer: BootstrapPagination::Rails, page_links: false
|
||||||
|
|
||||||
|
- if @questions.next_page
|
||||||
|
%button#load-more-btn.btn.btn-default{type: :button, data: { current_page: @questions.current_page }}
|
||||||
|
Load more
|
||||||
|
.visible-xs= render 'shared/links'
|
|
@ -0,0 +1,8 @@
|
||||||
|
$('#questions').append('<% @questions.each do |a|
|
||||||
|
%><%= j render 'shared/answerbox', a: a
|
||||||
|
%><% end %>');
|
||||||
|
<% if @questions.next_page %>
|
||||||
|
$('#pagination').html('<%= j will_paginate @questions, renderer: BootstrapPagination::Rails, page_links: false %>');
|
||||||
|
<% else %>
|
||||||
|
$('#pagination, #load-more-btn').remove();
|
||||||
|
<% end %>
|
|
@ -71,4 +71,5 @@ Rails.application.routes.draw do
|
||||||
match '/:username/q/:id', to: 'question#show', via: 'get', as: :show_user_question_alt
|
match '/:username/q/:id', to: 'question#show', via: 'get', as: :show_user_question_alt
|
||||||
match '/:username/followers(/p/:page)', to: 'user#followers', via: 'get', as: :show_user_followers_alt, defaults: {page: 1}
|
match '/:username/followers(/p/:page)', to: 'user#followers', via: 'get', as: :show_user_followers_alt, defaults: {page: 1}
|
||||||
match '/:username/friends(/p/:page)', to: 'user#friends', via: 'get', as: :show_user_friends_alt, defaults: {page: 1}
|
match '/:username/friends(/p/:page)', to: 'user#friends', via: 'get', as: :show_user_friends_alt, defaults: {page: 1}
|
||||||
|
match '/:username/questions(/p/:page)', to: 'user#questions', via: 'get', as: :show_user_questions, defaults: {page: 1}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue