diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index e9e8a3e3..335511ba 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -1,6 +1,7 @@ class UserController < ApplicationController def show @user = User.find_by_screen_name!(params[:username]) + @answers = @user.answers.reverse_order.paginate(page: params[:page]) end def edit diff --git a/app/views/user/show.html.haml b/app/views/user/show.html.haml index e618c408..7de8c7c3 100644 --- a/app/views/user/show.html.haml +++ b/app/views/user/show.html.haml @@ -15,4 +15,12 @@ Followings %span.badge#friend-count= @user.friend_count .col-md-9.col-xs-12.col-sm-9 - = render 'shared/questionbox' \ No newline at end of file + = render 'shared/questionbox' + - @answers.each do |a| + .panel.panel-default + .panel-body + %p + %strong= a.question.content + %small= user_screen_name a.question.user, a.question.author_is_anonymous + %hr/ + %p= a.content diff --git a/config/routes.rb b/config/routes.rb index 04250ffc..093fe72a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -30,7 +30,7 @@ Rails.application.routes.draw do match '/inbox', to: 'inbox#show', via: 'get' - match '/user/:username', to: 'user#show', via: 'get' - match '/@:username', to: 'user#show', via: 'get', as: :show_user_profile - match '/:username', to: 'user#show', via: 'get', as: :show_user_profile_alt + match '/user/:username(/p/:page)', to: 'user#show', via: 'get', defaults: {page: 1} + match '/@:username(/p/:page)', to: 'user#show', via: 'get', as: :show_user_profile, defaults: {page: 1} + match '/:username(/p/:page)', to: 'user#show', via: 'get', as: :show_user_profile_alt, defaults: {page: 1} end