added show answer thing

This commit is contained in:
nilsding 2014-12-05 07:02:23 +01:00
parent 2284daa161
commit 641fa1ddc3
6 changed files with 20 additions and 3 deletions

View file

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View file

@ -0,0 +1,5 @@
class AnswerController < ApplicationController
def show
@answer = Answer.find(params[:id])
end
end

View file

@ -0,0 +1,2 @@
module AnswerHelper
end

View file

@ -0,0 +1,3 @@
.container.j2-page
= render 'shared/answerbox', a: @answer

View file

@ -8,8 +8,9 @@
%h6.text-muted.media-heading.answerbox-question-user
= user_screen_name a.question.user, a.question.author_is_anonymous
asked
= time_ago_in_words(a.question.created_at)
ago
%a{href: show_user_answer_path(a.user.screen_name, a.id)}
= time_ago_in_words(a.question.created_at)
ago
%p.answerbox-question-text= a.question.content
.panel-body
%p= a.content
@ -27,4 +28,4 @@
- else
.row
.col-md-6.col-md-offset-6.col-sm-8.col-sm-offset-4.col-xs-6.col-xs-offset-6.text-right
= render 'shared/answerbox_buttons', a: a
= render 'shared/answerbox_buttons', a: a

View file

@ -1,4 +1,5 @@
Rails.application.routes.draw do
root 'static#index'
match '/about', to: 'static#about', via: 'get'
@ -38,5 +39,7 @@ Rails.application.routes.draw do
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/a/:id', to: 'answer#show', via: 'get', as: :show_user_answer
match '/:username(/p/:page)', to: 'user#show', via: 'get', as: :show_user_profile_alt, defaults: {page: 1}
match '/:username/a/:id', to: 'answer#show', via: 'get', as: :show_user_answer_alt
end