question page added

This commit is contained in:
Andreas N 2014-12-19 22:34:24 +01:00
parent e483714f44
commit 46c9ccc0ac
4 changed files with 32 additions and 0 deletions

View File

@ -36,4 +36,10 @@ class UserController < ApplicationController
@type = :friend
render 'show_follow'
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

View File

@ -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'

View File

@ -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 %>

View File

@ -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/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/questions(/p/:page)', to: 'user#questions', via: 'get', as: :show_user_questions, defaults: {page: 1}
end