fixed more stuff and more appropriate db seed
This commit is contained in:
parent
e643860c4a
commit
032cd732a3
10 changed files with 95 additions and 41 deletions
12
_reply_form
Normal file
12
_reply_form
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<div class="mb-10">
|
||||
<% if user_signed_in? %>
|
||||
<%= form_with(model: @reply, url: forum_thread_replies_url(@thread)) do |form| %>
|
||||
<div>
|
||||
<%= form.text_area :body, rows: 8, class:"border border-gray-300 w-1/2" %>
|
||||
<div>
|
||||
<%= form.submit class: "bg-gray-800 text-white rounded-lg p-5" %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
@ -29,8 +29,8 @@
|
|||
section.threadtitle {
|
||||
border: 1px solid black;
|
||||
overflow: scroll;
|
||||
padding: 1px;
|
||||
}
|
||||
margin-bottom: 40px;
|
||||
text-align: center; }
|
||||
|
||||
section.reply {
|
||||
padding: 5px;
|
||||
|
|
@ -42,3 +42,11 @@
|
|||
overflow: scroll;
|
||||
border: 2px dotted white;
|
||||
}
|
||||
|
||||
section.post {
|
||||
border: 3px inset white;
|
||||
padding-left: 3%;
|
||||
padding-right: 3%;
|
||||
padding-bottom: 3%;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,13 +3,12 @@ class ForumThreadsController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
id = params.extract_value(:id)
|
||||
@category = Category.find(params[:category_id])
|
||||
|
||||
@forum_topic = @category.forum_topics.find(params[:forum_topic_id])
|
||||
@forum_thread = @category.forum_topics.forum_threads.find(params[:forum_thread_id])
|
||||
end
|
||||
|
||||
@forum_thread = @forum_topic.forum_threads.find(params[:id])
|
||||
@forum_thread.replies = Reply.all
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,4 +15,8 @@ def create
|
|||
|
||||
@reply.save
|
||||
end
|
||||
def show
|
||||
|
||||
@replies = Reply.all
|
||||
@thread.replies = Reply.all
|
||||
end
|
||||
|
|
|
|||
10
app/views/_reply_form.html.erb
Normal file
10
app/views/_reply_form.html.erb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<% @thread.replies.each do | reply | %>
|
||||
<div class="p-3 border-b border-gray-100 w-1/2">
|
||||
<div class="text-sm">
|
||||
<a class="text-blue-500" href=""><%= reply.user.email %></a> said <span class="text-gray-400"><%= reply.created_at_for_humans %></span>
|
||||
</div>
|
||||
<div class="text-gray-700">
|
||||
<p class="reply-body"><%= reply.body %></p>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
<div class="mb-10">
|
||||
<% if user_signed_in? %>
|
||||
<%= form_with(model: @reply, url: forum_thread_replies_url(@thread)) do |form| %>
|
||||
<div>
|
||||
<%= form.text_area :body, rows: 8, class:"border border-gray-300 w-1/2" %>
|
||||
<div>
|
||||
<%= form.submit class: "bg-gray-800 text-white rounded-lg p-5" %>
|
||||
<% @forum_thread.replies.each do | reply | %>
|
||||
<div class="p-3 border-b border-gray-100 w-1/2">
|
||||
<div class="text-sm">
|
||||
<a class="text-blue-500" href=""><%= reply.user.email %></a> said <span class="text-gray-400"><%= reply.created_at %></span>
|
||||
</div>
|
||||
<div class="text-gray-700">
|
||||
<p class="reply-body"><%= reply.body %></p>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
|||
10
app/views/forum_threads/reply_form.html.erb
Normal file
10
app/views/forum_threads/reply_form.html.erb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<% @thread.replies.each do | reply | %>
|
||||
<div class="p-3 border-b border-gray-100 w-1/2">
|
||||
<div class="text-sm">
|
||||
<a class="text-blue-500" href=""><%= reply.user.email %></a> said <span class="text-gray-400"><%= reply.created_at_for_humans %></span>
|
||||
</div>
|
||||
<div class="text-gray-700">
|
||||
<p class="reply-body"><%= reply.body %></p>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
<section class="threadindex">
|
||||
<div class="box">
|
||||
<h1><%= @thread.title %></h1>
|
||||
<article><%= @thread.body %></article>
|
||||
<section class="post">
|
||||
<section class="threadtitle"> <h1><%= @forum_thread.title %></h1>
|
||||
</section> <article><%= @forum_thread.body %></article>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
<%= render "_reply_form" %>
|
||||
</section>
|
||||
<hr /><section class="replies"
|
||||
<%= render 'forum_threads/reply_form' %>
|
||||
<hr>
|
||||
<% @thread.replies.each do | reply | %>
|
||||
<% @forum_thread.replies.each do | reply | %>
|
||||
<div class="box">
|
||||
<div>
|
||||
<%= reply.user.email %> said <% reply.created_at %>:
|
||||
</div>
|
||||
<p><%= reply.body %></p>
|
||||
</div>
|
||||
</section>
|
||||
<% end %>
|
||||
</section>
|
||||
|
|
|
|||
10
app/views/reply_form.html.erb
Normal file
10
app/views/reply_form.html.erb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<% @thread.replies.each do | reply | %>
|
||||
<div class="p-3 border-b border-gray-100 w-1/2">
|
||||
<div class="text-sm">
|
||||
<a class="text-blue-500" href=""><%= reply.user.email %></a> said <span class="text-gray-400"><%= reply.created_at_for_humans %></span>
|
||||
</div>
|
||||
<div class="text-gray-700">
|
||||
<p class="reply-body"><%= reply.body %></p>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
27
db/seeds.rb
27
db/seeds.rb
|
|
@ -1,5 +1,11 @@
|
|||
user = User.create!(
|
||||
email: "nahlebiscanon@alexkurtzman.com",
|
||||
email: "nahlisha@alexkurtzman.com",
|
||||
password: "password",
|
||||
password_confirmation: "password"
|
||||
)
|
||||
|
||||
user2 = User.create!(
|
||||
email: "toxicyuri@toxicyuri.com",
|
||||
password: "password",
|
||||
password_confirmation: "password"
|
||||
)
|
||||
|
|
@ -23,30 +29,27 @@ topic2 = ForumTopic.create!(
|
|||
|
||||
|
||||
thread1 = ForumThread.create!(
|
||||
title: "NAHLEB TRANSFEM CALEB",
|
||||
title: "WOMENRGAY666",
|
||||
body: "lorem ipsum text",
|
||||
forum_topic: topic1
|
||||
)
|
||||
|
||||
thread2 = ForumThread.create!(
|
||||
title: "samjett rights",
|
||||
body: "can you be a sugar mommy in a post-scarcity world",
|
||||
body: "can you be a sugar mommy in star trek",
|
||||
forum_topic: topic2
|
||||
)
|
||||
|
||||
|
||||
2.times do
|
||||
Reply.create!(
|
||||
body: "nahleb is canon brother",
|
||||
reply1 = Reply.create!(
|
||||
body: "aliens are hot",
|
||||
thread_id: thread1.id,
|
||||
user: user
|
||||
)
|
||||
end
|
||||
|
||||
2.times do
|
||||
Reply.create!(
|
||||
body: "nahleb is canon brother",
|
||||
reply2 = Reply.create!(
|
||||
body: "i love women",
|
||||
thread_id: thread2.id,
|
||||
user: user
|
||||
user: user2
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue