Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/answers.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
File renamed without changes.
14 changes: 12 additions & 2 deletions app/views/answers/_individual_answer.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
<li>
<%=answer.description%></li>
<div class= "add-answer-comment" id = "<%=answer.id%>">
<br><li><b class="blue"><%=answer.description%></b></li>

<% if logged_in? %>
<a class= 'add-answer-comment-link' href= "#" >Add a comment to this answer</a><br>
<% end %>

<ul class ="answer-comment-list">
<% answer.comments.each do |comment| %>
<%= erb :'/comments/_individual_comment', locals: {answer: answer, question: @question, comment: comment} %>
<% end %>
</ul>

<form action = "/questions/<%=question.id%>/answers/<%=answer.id%>/answer_comment" method = "POST" class= "answer-comment-form hidden">
<input id= "answer-comment-description" type ="text" name= "description" placeholder= "Your Comment">
<input type ="submit" value= "Submit Comment">
</form>
</div>

Empty file removed app/views/index.erb
Empty file.
2 changes: 2 additions & 0 deletions app/views/layout.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@

<div id="logo-header">
<a href="/"><img src="../traveloverflow.png" width="507px" height="79,4px"></a>
<% if logged_in? %>
<h3 id="ask-a-question-button"><a href="/questions/new">Ask a Question</a></h3>
<% end %>
<h3 class="questions-button"><a href="/questions">Questions</a></h3>

</div>
Expand Down
1 change: 0 additions & 1 deletion app/views/questions/_individual_question.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<tr>
<td><a id = "question-title" href="/questions/<%=question.id%>"><%=question.title%></a></td>
</tr>
<!-- Stretch: Add username of the person who asked the question, and a post date -->
5 changes: 4 additions & 1 deletion app/views/questions/index.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<div class= "container">
<h1>Questions</h1>

<div class="profile-container">
<h1 class="orange-underline">Questions</h1>
</div>

<h3><%= erb :'/_errors', layout: false %></h3>
<form id = "question-form" class = "hidden" action = "/questions" method = "POST">
Expand Down
45 changes: 25 additions & 20 deletions app/views/questions/show.erb
Original file line number Diff line number Diff line change
@@ -1,52 +1,57 @@
<div class= "container">
<div class="question-title">
<h1><%=@question.title%><span class="vote-button"><%= erb :_vote_button %></span></h1>
<h1><%=@question.title%><% if logged_in? %><span class="vote-button"><%= erb :_question_vote_button %></span><% end %></h1>
</div>

<p class="question-description"><%=@question.description%></p>

<ul id ="question-comment-list">
<% @question.comments.each do |comment| %>
<div class = "question">
<%= erb :'/comments/_individual_comment', locals: {answer: @answer, question: @question, comment: comment} %>
<% end %>
</ul>
<div class="comments-container">
<h4 class="orange-underline">Comments</h4>

<a class= 'add-question-comment-link' href= "#" >Add a comment to this question</a><br>
<% if logged_in? %>
<a class='add-question-comment-link' href= "#" ><h4 class="white">Add a comment</a></h4>
<% end %>

<form action = "/questions/<%=@question.id%>/question_comment" method = "POST" class= "question-comment-form hidden">
<input id = "#question-comment-description" type ="text" name= "description" placeholder= "Your Comment">
<input type ="submit" value= "Submit Comment">
</form>

</div>

<ul id ="question-comment-list">
<% @question.comments.each do |comment| %>
<div class = "question">
<%= erb :'/comments/_individual_comment', locals: {answer: @answer, question: @question, comment: comment} %>
<% end %>
</ul>

<form action = "/questions/<%=@question.id%>/question_comment" method = "POST" class= "comment-form hidden">
<input type ="text" name= "description" placeholder= "Your Comment">
<input type ="submit" value= "Submit Comment">
</form>

</div>

<div class="answer-container">
<h1 class="orange-underline">Answers</h1></div>

<ul id= "answer-list">
<% @answers.each do |answer| %>
<div class = "answer" id = "<%=answer.id%>">
<%= erb :'/answers/_individual_answer', locals: {answer: answer, question: @question} %>
<ul class ="answer-comment-list">
<% answer.comments.each do |comment| %>
<%= erb :'/comments/_individual_comment', locals: {answer: answer, question: @question, comment: comment} %>
<% end %>
</ul>
<% end %>
</div>
</ul>

<% if logged_in? %>
<h3><a id= "add-answer-button" href= "#">Add an Answer</a></h3>
<% end %>

<form id= "answer-form" action = "/questions/<%=@question.id%>/answers" method = "POST" class= "hidden">
<input type ="text" name= "description" placeholder= "Your Answer">
<input type ="submit" value= "Submit Answer">
</form>

<% @answers.each do |answer| %>
<div class = "answer">
<%= erb :'/answers/_individual_answer', locals: {answer: answer, question: @question} %>
<% end %>
</div>
</ul>
</div>

</div>
21 changes: 15 additions & 6 deletions app/views/sessions/login.erb
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
<div class="container">
<h1>Login to TravelOverflow</h1>

<div class="profile-container">
<div class="orange-underline">
<h1 class="blue">Login to Travel Overflow!</h1>
</div>
</div>

<% if @errors %>
<% @errors.each do |error| %>
<%= error %>
<% end %>
<% end %>

<div class="sign-form-container">

<form action = "/login" method = "POST">
<input type = "text" name= "username" placeholder = "username">
<input type = "password" name = "password" placeholder = "password">
<input type = "submit" value = "Login">
<input type = "text" name= "username" placeholder = "username" class="title-box"><br>
<input type = "password" name = "password" placeholder = "password" class="title-box"><br>
<input type = "submit" value = "Login" class="register-button">
</form>

<h3>Not registered?<a href="/users/new"> Sign up now!</a></h3>

</div>

<div class="profile-container">
<h3 class="blue">Not registered?<a href="/login" class="orange"> Sign up now!</a></h4>
</div>

</div>
22 changes: 18 additions & 4 deletions app/views/users/new.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
<div class="container">
<h1>Register for TravelOverflow!</h1>

<div class="profile-container">
<div class="orange-underline">
<h1 class="blue">Register for Travel Overflow!</h1>
</div>
</div>

<% if @errors %>
<% errors.each do |error| %>
<%= error %>
<% end %>
<% end %>

<div class="sign-form-container">

<form action = "/users" method = "POST">
<input type = "text" name= "user[username]" placeholder = "username">
<input type = "password" name= "user[password]" placeholder = "password">
<input type = "submit" value = "Register">
<input type = "text" name= "user[username]" placeholder = "username" class="title-box"><br>
<input type = "password" name= "user[password]" placeholder = "password" class="title-box"><br>
<input type = "submit" value = "Register" class="register-button">
</form>

</div>

<div class="profile-container">
<h3 class="blue">Already registered?<a href="/login" class="orange"> Login in!</a></h4>
</div>

</div>
51 changes: 37 additions & 14 deletions app/views/users/show.erb
Original file line number Diff line number Diff line change
@@ -1,39 +1,62 @@
<div class="container">
<h1>Welcome, <%= @user.username.capitalize %>!</h1>
<h1 class="blue">Welcome, <%= @user.username.capitalize %>!</h1>

<h2>Questions</h2>
<div class="profile-container">
<h2 class="orange-underline">Your Questions</h2>
<table class="question-table">
<% @user_questions.each do |question| %>
<p><a href="/questions/<%=question.id%>"><%= question.title %></a></p>
<tr>
<td><a href="/questions/<%=question.id%>"><%= question.title %></a></td>
<% end %>
</tr>
</table>
</div>

<h2>Answers</h2>
<div class="profile-container">
<h2 class="orange-underline">Your Answers</h2>
<table class="question-table">
<% @user_answers.each do |answer| %>
<tr>
<% @question_answered %>
<p><a href="/questions/<%=@question_answered.id%>"><%=@question_answered.title%></a> <%= answer.description %></p>
<td>Question:<a href="/questions/<%=@question_answered.id%>"> <%=@question_answered.title%></a><br>Answer: <%= answer.description %></td>
<% end %>
</tr>
</table>
</div>

<h2>Comments on Questions</h2>
<div class="profile-container">
<h2 class="orange-underline">Comments on Questions</h2>
<table class="question-table">
<% @user_comments.each do |comment| %>
<% if comment.commentable_type == "Question" %>
<% @commented_question_id = comment.commentable_id %>
<% @question_commented_on = Question.find_by(id: @commented_question_id)%>
<a href="/questions/<%=@commented_question_id%>"><%= @question_commented_on.title %></a>
<%= comment.description %>
<tr>
<td>Question: <a href="/questions/<%=@commented_question_id%>"><%= @question_commented_on.title %></a><br>
Comment: <%= comment.description %></td>
<% end %>
<% end %>
</tr>
</table>
</div>

<h2>Comments on Answers</h2>
<div class="profile-container">
<h2 class="orange-underline">Comments on Answers</h2>
<table class="question-table">
<% @user_comments.each do |comment| %>
<% if comment.commentable_type == "Answer" %>
<% @commented_answer_id = comment.commentable_id %>
<% @answer_commented_on = Answer.find_by(id: @commented_answer_id)%>
<% @question_of_commented_answer = Question.find_by(id: @answer_commented_on.question_id) %>

<p>Question: <a href="/question/<%@question_of_commented_answer.id%>"><%=@question_of_commented_answer.title%></a></p>
<p>Answer:<%= @answer_commented_on.description %></p>
<p>Comment:<%= comment.description %></p>
<% end %>
<tr>
<td>Question: <a href="/question/<%@question_of_commented_answer.id%>"><%=@question_of_commented_answer.title%></a><br>
Answer: <%= @answer_commented_on.description %><br>
Comment: <%= comment.description %>
<% end %></td>
<% end %>
</tr>
</table>
</div>


</div>
Expand Down
Loading