diff --git a/app/controllers/answers.rb b/app/controllers/answers.rb index d880504..fbd14a4 100644 --- a/app/controllers/answers.rb +++ b/app/controllers/answers.rb @@ -1,6 +1,6 @@ post '/questions/:question_id/answers' do @question = Question.find_by(id: params[:question_id]) - @answer = Answer.new(description: params[:description]) + @answer = Answer.new(description: params[:description], user_id: current_user.id) @answers = @question.answers @comments = @answer.comments if @answer.save @@ -27,3 +27,28 @@ redirect "/questions/#{@question.id}" end end + +# post '/questions/:question_id/answers/:answer_id/answer/upvote' do +# @question = Question.find_by(id: params[:question_id]) +# @answer = Answer.find_by(id: params[:answer_id]) +# binding.pry +# @answer.votes.create(value: 1) + +# if request.xhr? +# {points: @answer.points}.to_json +# else +# redirect "/questions/#{@question.id}" +# end +# end + +# post '/questions/:question_id/downvote' do +# @question = Question.find_by(id: params[:question_id]) +# @answer = Answer.find_by(id: params[:answer_id]) +# @answer.votes.create(value: -1) + +# if request.xhr? +# {points: @answer.points}.to_json +# else +# redirect "/questions/#{@question.id}" +# end +# end diff --git a/app/views/_answer_vote_button.erb b/app/views/_answer_vote_button.erb new file mode 100644 index 0000000..e69de29 diff --git a/app/views/_comment_vote_button.erb b/app/views/_comment_vote_button.erb new file mode 100644 index 0000000..e69de29 diff --git a/app/views/_vote_button.erb b/app/views/_question_vote_button.erb similarity index 100% rename from app/views/_vote_button.erb rename to app/views/_question_vote_button.erb diff --git a/app/views/questions/show.erb b/app/views/questions/show.erb index 06270a4..fd5828b 100644 --- a/app/views/questions/show.erb +++ b/app/views/questions/show.erb @@ -1,37 +1,54 @@
-

<%=@question.title%><%= erb :_vote_button %>

+

<%=@question.title%><%= erb :_question_vote_button %>

<%=@question.description%>

- +
+

Comments

-Add a comment to this question
+

Add a comment

-
+ + +
+
+

Answers

+
-

Add an Answer

- - + diff --git a/public/css/application.css b/public/css/application.css index f50e465..09c3c24 100644 --- a/public/css/application.css +++ b/public/css/application.css @@ -4,7 +4,7 @@ body { .container { margin-top: 12em; text-align: center; - padding-bottom: 5em; + padding-bottom: 15em; } #question-form { @@ -31,6 +31,7 @@ body { display: inline; margin-top: 0; } + .vote-button { font-size: 12px; display: inline-block; @@ -42,6 +43,52 @@ body { margin-right: auto; } + + + +/* Question Show Page */ + +.orange-underline { + border-bottom: 5px solid; + border-color: #D86E3E; + color: #3A5863; +} + +.answer-container { + margin-left: auto; + margin-right: auto; + margin-top: 3em; + width: 40em; + color: #3A5863; + line-height: 2em; +} + +.answer-container ul { + list-style-type: none; + padding: 0; +} +.add-question-comment-link a { + color: #3A5863; +} + +.add-question-comment-link a:hover { + color: #D86E3E; +} + +.comments-container { + margin-left: auto; + margin-right: auto; + margin-top: 3em; + width: 20em; + color: #3A5863; + line-height: 2em; +} + +.comments-container ul { + list-style-type: none; + padding: 0; +} + .question-table td { padding: 2em; background-color: #3A5863; @@ -71,15 +118,10 @@ body { .question-description { margin-left: auto; margin-right: auto; - width: 55em; - padding-right: 5em; - padding-left: 5em; -} - -.question-description p { - font-size: 120%; - color: #3A5863; + width: 40em; word-wrap: break-word; + color: #3A5863; + font-size: 120%; } diff --git a/public/css/normalize.css b/public/css/normalize.css index 15f23c5..0db76b8 100644 --- a/public/css/normalize.css +++ b/public/css/normalize.css @@ -85,6 +85,7 @@ template { a { background: transparent; text-decoration: none; + color: #3A5863; } /** @@ -94,6 +95,7 @@ a { a:active, a:hover { outline: 0; + color: #D86E3E; } /* Text-level semantics diff --git a/public/js/application.js b/public/js/application.js index 341bd02..0e86fb1 100644 --- a/public/js/application.js +++ b/public/js/application.js @@ -12,6 +12,10 @@ $(document).ready(function() { $(".total-points").text(voteObject.points); }) }); + + + + $('#ask-a-question-button').on("click", "a", function(e){ e.preventDefault(); $('#question-form').show();