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 {
|
section.threadtitle {
|
||||||
border: 1px solid black;
|
border: 1px solid black;
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
padding: 1px;
|
margin-bottom: 40px;
|
||||||
}
|
text-align: center; }
|
||||||
|
|
||||||
section.reply {
|
section.reply {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
|
|
@ -42,3 +42,11 @@
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
border: 2px dotted white;
|
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
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
id = params.extract_value(:id)
|
|
||||||
@category = Category.find(params[:category_id])
|
@category = Category.find(params[:category_id])
|
||||||
|
|
||||||
@forum_topic = @category.forum_topics.find(params[:forum_topic_id])
|
@forum_topic = @category.forum_topics.find(params[:forum_topic_id])
|
||||||
@forum_thread = @category.forum_topics.forum_threads.find(params[:forum_thread_id])
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
@forum_thread = @forum_topic.forum_threads.find(params[:id])
|
||||||
end
|
@forum_thread.replies = Reply.all
|
||||||
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,8 @@ def create
|
||||||
|
|
||||||
@reply.save
|
@reply.save
|
||||||
end
|
end
|
||||||
|
def show
|
||||||
|
|
||||||
|
@replies = Reply.all
|
||||||
|
@thread.replies = Reply.all
|
||||||
end
|
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">
|
<% @forum_thread.replies.each do | reply | %>
|
||||||
<% if user_signed_in? %>
|
<div class="p-3 border-b border-gray-100 w-1/2">
|
||||||
<%= form_with(model: @reply, url: forum_thread_replies_url(@thread)) do |form| %>
|
<div class="text-sm">
|
||||||
<div>
|
<a class="text-blue-500" href=""><%= reply.user.email %></a> said <span class="text-gray-400"><%= reply.created_at %></span>
|
||||||
<%= form.text_area :body, rows: 8, class:"border border-gray-300 w-1/2" %>
|
</div>
|
||||||
<div>
|
<div class="text-gray-700">
|
||||||
<%= form.submit class: "bg-gray-800 text-white rounded-lg p-5" %>
|
<p class="reply-body"><%= reply.body %></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% 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">
|
<section class="threadindex">
|
||||||
<div class="box">
|
<section class="post">
|
||||||
<h1><%= @thread.title %></h1>
|
<section class="threadtitle"> <h1><%= @forum_thread.title %></h1>
|
||||||
<article><%= @thread.body %></article>
|
</section> <article><%= @forum_thread.body %></article>
|
||||||
</div>
|
</div>
|
||||||
|
</section>
|
||||||
<hr />
|
<hr /><section class="replies"
|
||||||
<%= render "_reply_form" %>
|
<%= render 'forum_threads/reply_form' %>
|
||||||
<hr>
|
<hr>
|
||||||
<% @thread.replies.each do | reply | %>
|
<% @forum_thread.replies.each do | reply | %>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div>
|
<div>
|
||||||
<%= reply.user.email %> said <% reply.created_at %>:
|
<%= reply.user.email %> said <% reply.created_at %>:
|
||||||
</div>
|
</div>
|
||||||
<p><%= reply.body %></p>
|
<p><%= reply.body %></p>
|
||||||
</div>
|
</section>
|
||||||
<% end %>
|
<% end %>
|
||||||
</section>
|
</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!(
|
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: "password",
|
||||||
password_confirmation: "password"
|
password_confirmation: "password"
|
||||||
)
|
)
|
||||||
|
|
@ -23,30 +29,27 @@ topic2 = ForumTopic.create!(
|
||||||
|
|
||||||
|
|
||||||
thread1 = ForumThread.create!(
|
thread1 = ForumThread.create!(
|
||||||
title: "NAHLEB TRANSFEM CALEB",
|
title: "WOMENRGAY666",
|
||||||
body: "lorem ipsum text",
|
body: "lorem ipsum text",
|
||||||
forum_topic: topic1
|
forum_topic: topic1
|
||||||
)
|
)
|
||||||
|
|
||||||
thread2 = ForumThread.create!(
|
thread2 = ForumThread.create!(
|
||||||
title: "samjett rights",
|
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
|
forum_topic: topic2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
2.times do
|
reply1 = Reply.create!(
|
||||||
Reply.create!(
|
body: "aliens are hot",
|
||||||
body: "nahleb is canon brother",
|
|
||||||
thread_id: thread1.id,
|
thread_id: thread1.id,
|
||||||
user: user
|
user: user
|
||||||
)
|
)
|
||||||
end
|
|
||||||
|
|
||||||
2.times do
|
reply2 = Reply.create!(
|
||||||
Reply.create!(
|
body: "i love women",
|
||||||
body: "nahleb is canon brother",
|
|
||||||
thread_id: thread2.id,
|
thread_id: thread2.id,
|
||||||
user: user
|
user: user2
|
||||||
)
|
)
|
||||||
end
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue