From 032cd732a3ec559e6becd1fa8b8bceb1b43c221d Mon Sep 17 00:00:00 2001 From: root Date: Wed, 18 Mar 2026 01:57:09 +0000 Subject: [PATCH] fixed more stuff and more appropriate db seed --- _reply_form | 12 +++++++++ app/assets/stylesheets/application.css | 12 +++++++-- app/controllers/forum_threads_controller.rb | 13 +++++----- app/controllers/replies_controller.rb | 4 +++ app/views/_reply_form.html.erb | 10 ++++++++ app/views/forum_threads/_reply_form.html.erb | 22 ++++++++-------- app/views/forum_threads/reply_form.html.erb | 10 ++++++++ app/views/forum_threads/show.html.erb | 16 ++++++------ app/views/reply_form.html.erb | 10 ++++++++ db/seeds.rb | 27 +++++++++++--------- 10 files changed, 95 insertions(+), 41 deletions(-) create mode 100644 _reply_form create mode 100644 app/views/_reply_form.html.erb create mode 100644 app/views/forum_threads/reply_form.html.erb create mode 100644 app/views/reply_form.html.erb diff --git a/_reply_form b/_reply_form new file mode 100644 index 0000000..5141436 --- /dev/null +++ b/_reply_form @@ -0,0 +1,12 @@ +
+ <% if user_signed_in? %> + <%= form_with(model: @reply, url: forum_thread_replies_url(@thread)) do |form| %> +
+ <%= form.text_area :body, rows: 8, class:"border border-gray-300 w-1/2" %> +
+ <%= form.submit class: "bg-gray-800 text-white rounded-lg p-5" %> +
+
+ <% end %> + <% end %> +
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 0f7e9f7..a793aeb 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -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%; +} + diff --git a/app/controllers/forum_threads_controller.rb b/app/controllers/forum_threads_controller.rb index f23df34..c0aee60 100644 --- a/app/controllers/forum_threads_controller.rb +++ b/app/controllers/forum_threads_controller.rb @@ -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 + @category = Category.find(params[:category_id]) - end - end + @forum_topic = @category.forum_topics.find(params[:forum_topic_id]) + + @forum_thread = @forum_topic.forum_threads.find(params[:id]) + @forum_thread.replies = Reply.all end +end diff --git a/app/controllers/replies_controller.rb b/app/controllers/replies_controller.rb index d5641f0..5fc16d8 100644 --- a/app/controllers/replies_controller.rb +++ b/app/controllers/replies_controller.rb @@ -15,4 +15,8 @@ def create @reply.save end +def show + +@replies = Reply.all +@thread.replies = Reply.all end diff --git a/app/views/_reply_form.html.erb b/app/views/_reply_form.html.erb new file mode 100644 index 0000000..649e7bb --- /dev/null +++ b/app/views/_reply_form.html.erb @@ -0,0 +1,10 @@ +<% @thread.replies.each do | reply | %> +
+
+ <%= reply.user.email %> said <%= reply.created_at_for_humans %> +
+
+

<%= reply.body %>

+
+
+<% end %> diff --git a/app/views/forum_threads/_reply_form.html.erb b/app/views/forum_threads/_reply_form.html.erb index 5141436..ba92d0d 100644 --- a/app/views/forum_threads/_reply_form.html.erb +++ b/app/views/forum_threads/_reply_form.html.erb @@ -1,12 +1,10 @@ -
- <% if user_signed_in? %> - <%= form_with(model: @reply, url: forum_thread_replies_url(@thread)) do |form| %> -
- <%= form.text_area :body, rows: 8, class:"border border-gray-300 w-1/2" %> -
- <%= form.submit class: "bg-gray-800 text-white rounded-lg p-5" %> -
-
- <% end %> - <% end %> -
+<% @forum_thread.replies.each do | reply | %> +
+
+ <%= reply.user.email %> said <%= reply.created_at %> +
+
+

<%= reply.body %>

+
+
+<% end %> diff --git a/app/views/forum_threads/reply_form.html.erb b/app/views/forum_threads/reply_form.html.erb new file mode 100644 index 0000000..649e7bb --- /dev/null +++ b/app/views/forum_threads/reply_form.html.erb @@ -0,0 +1,10 @@ +<% @thread.replies.each do | reply | %> +
+
+ <%= reply.user.email %> said <%= reply.created_at_for_humans %> +
+
+

<%= reply.body %>

+
+
+<% end %> diff --git a/app/views/forum_threads/show.html.erb b/app/views/forum_threads/show.html.erb index 01ea411..e6010ea 100644 --- a/app/views/forum_threads/show.html.erb +++ b/app/views/forum_threads/show.html.erb @@ -1,18 +1,18 @@
-
-

<%= @thread.title %>

-
<%= @thread.body %>
+
+

<%= @forum_thread.title %>

+
<%= @forum_thread.body %>
- -
- <%= render "_reply_form" %> +
+

- <% @thread.replies.each do | reply | %> + <% @forum_thread.replies.each do | reply | %>
<%= reply.user.email %> said <% reply.created_at %>:

<%= reply.body %>

-
+
<% end %> diff --git a/app/views/reply_form.html.erb b/app/views/reply_form.html.erb new file mode 100644 index 0000000..649e7bb --- /dev/null +++ b/app/views/reply_form.html.erb @@ -0,0 +1,10 @@ +<% @thread.replies.each do | reply | %> +
+
+ <%= reply.user.email %> said <%= reply.created_at_for_humans %> +
+
+

<%= reply.body %>

+
+
+<% end %> diff --git a/db/seeds.rb b/db/seeds.rb index 013ff9b..c70905e 100644 --- a/db/seeds.rb +++ b/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 +