answers are now shown on the user page

This commit is contained in:
nilsding 2014-11-12 20:40:24 +01:00
parent 57dc1f51c6
commit b1a1c83163
3 changed files with 13 additions and 4 deletions

View File

@ -1,6 +1,7 @@
class UserController < ApplicationController 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])
end end
def edit def edit

View File

@ -16,3 +16,11 @@
%span.badge#friend-count= @user.friend_count %span.badge#friend-count= @user.friend_count
.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|
.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

View File

@ -30,7 +30,7 @@ Rails.application.routes.draw do
match '/inbox', to: 'inbox#show', via: 'get' match '/inbox', to: 'inbox#show', via: 'get'
match '/user/:username', to: 'user#show', via: 'get' match '/user/:username(/p/:page)', to: 'user#show', via: 'get', defaults: {page: 1}
match '/@:username', to: 'user#show', via: 'get', as: :show_user_profile match '/@:username(/p/:page)', to: 'user#show', via: 'get', as: :show_user_profile, defaults: {page: 1}
match '/:username', to: 'user#show', via: 'get', as: :show_user_profile_alt match '/:username(/p/:page)', to: 'user#show', via: 'get', as: :show_user_profile_alt, defaults: {page: 1}
end end