From e643860c4a40bfa87c314b51749e9590b0e719df Mon Sep 17 00:00:00 2001 From: root Date: Wed, 18 Mar 2026 01:09:39 +0000 Subject: [PATCH] cleaning some shit --- app/controllers/categories_controller.rb | 28 ++++++-- app/controllers/forum_threads_controller.rb | 13 ++-- app/controllers/forum_topics_controller.rb | 23 ++++--- app/views/categories/index.html.erb | 6 +- app/views/forum_topics/show.html.erb | 6 +- db/seeds.rb | 71 +++++++++++++-------- 6 files changed, 97 insertions(+), 50 deletions(-) diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 5d1f74b..30877e0 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -5,11 +5,29 @@ def index end def show -id = params.extract_value(:id) -@category = Category.find_by_id(id) - @forum_topics = @category.forum_topics - end - +#id = params.extract_value(:id) + + # @category = Category.find_by(id: params[:category_id]) + #@forum_topics = @categories.forum_topics.find_by(params[:forum_topic_id]) + + #@forum_threads = @categories.forum_topics.forum_threads.find_by(params[:forum_thread_id]) + + #end +@forum_topics = ForumTopic.all +@category = Category.find_by(id: params[:id]) +#@forum_topics = @category&.forum_topics&.find_by(id: params[:forum_topic_id]) + +@forum_threads = @category&.forum_topics + &.find_by(id: params[:forum_topic_id]) + &.forum_threads + &.find_by(id: params[:forum_thread_id]) end +private + +def category_params + params.require(:title, :description) + +end +end diff --git a/app/controllers/forum_threads_controller.rb b/app/controllers/forum_threads_controller.rb index 064facf..f23df34 100644 --- a/app/controllers/forum_threads_controller.rb +++ b/app/controllers/forum_threads_controller.rb @@ -1,10 +1,15 @@ class ForumThreadsController < ApplicationController def index - @threads = ForumThread.all - end +end + def show - id = params.extract_value(:id) - @thread = ForumThread.find_by_id(id) + 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 + + end end end diff --git a/app/controllers/forum_topics_controller.rb b/app/controllers/forum_topics_controller.rb index 5f74d8b..bd5cc3e 100644 --- a/app/controllers/forum_topics_controller.rb +++ b/app/controllers/forum_topics_controller.rb @@ -1,8 +1,4 @@ class ForumTopicsController < ApplicationController -def show - id = params.extract_value(:id) - @thread = ForumThread.find_by_id(id) -end def index @@ -10,9 +6,18 @@ def index end def show - id = params.extract_value(:id) - @forum_topics = ForumTopic.find_by_id(id) - @threads = ForumThread.all - @thread = ForumThread.find_by_id(id) - end + + @category = Category.find(params[:category_id]) + #@forum_topics = ForumTopic.all + #@forum_thread = @category&.forum_topics&.forum_thread(params[:forum_thread_id]) + @forum_topic = @category.forum_topics.find(params[:id]) + + @forum_threads = @forum_topic.forum_threads end + +end +private +def params + params.require(:forum_topic, :title).permit( :description) +end + diff --git a/app/views/categories/index.html.erb b/app/views/categories/index.html.erb index b652d08..a117d1e 100644 --- a/app/views/categories/index.html.erb +++ b/app/views/categories/index.html.erb @@ -1,4 +1,8 @@ -
<% @categories.each do | category | %> +

SILLYFORUMZ!

+

welcome to the worst forum site on the web <3

+
+

Forum Categories

+
<% @categories.each do | category | %>

<%= category.title %> <%= link_to 'Show', category_path(category) %>

<%= category.description %>

diff --git a/app/views/forum_topics/show.html.erb b/app/views/forum_topics/show.html.erb index 82237fd..b65a767 100644 --- a/app/views/forum_topics/show.html.erb +++ b/app/views/forum_topics/show.html.erb @@ -1,8 +1,8 @@
-

<%= @forum_topics.title %>

- <% @threads.each do |thread| %>
- <%= thread.title %>
<%= truncate(@thread.body, length: 200) %>

+

<%= @forum_topic.title %>

+ <% @forum_threads.each do |forum_thread| %>
+ <%= forum_thread.title %> | <%= link_to 'Show', category_forum_topic_forum_thread_path(@category, @forum_topic, forum_thread) %>
<%= truncate(forum_thread.body, length: 200) %>

<% end %>
diff --git a/db/seeds.rb b/db/seeds.rb index ce7e596..013ff9b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,37 +1,52 @@ - user = User.create!( email: "nahlebiscanon@alexkurtzman.com", password: "password", password_confirmation: "password" ) +cat1 = Category.create!(title: "Femslash Creations", description: "This is a description") +cat2 = Category.create!(title: "Toxic Yuri Creations", description: "This is a description") +cat3 = Category.create!(title: "Yuricest Creations", description: "This is a description") + + +topic1 = ForumTopic.create!( + title: "Writing - WIP", + description: "For sharing writing works in progress and such.", + category: cat1 +) + +topic2 = ForumTopic.create!( + title: "Art - WIP", + description: "For sharing visual art works in progress.", + category: cat1 +) + + +thread1 = ForumThread.create!( + title: "NAHLEB TRANSFEM CALEB", + 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", + forum_topic: topic2 +) + + 2.times do - category = Category.create!( - title: "Femslash Creations", - description: "This is a description" + Reply.create!( + body: "nahleb is canon brother", + thread_id: thread1.id, + user: user + ) +end + +2.times do + Reply.create!( + body: "nahleb is canon brother", + thread_id: thread2.id, + user: user ) - - 2.times do - topic = ForumTopic.create!( - title: "Sample Topic", - description: "This is a topic description", - category: category - ) - - 2.times do - thread = ForumThread.create!( - title: "Thread title", - body: "Thread body", - forum_topic: topic - ) - - 2.times do - Reply.create!( - body: "nahleb is canon brother", - thread_id: thread.id, - user: user - ) - end - end - end end