cleaning some shit

This commit is contained in:
root 2026-03-18 01:09:39 +00:00
parent 2a0067da77
commit e643860c4a
6 changed files with 97 additions and 50 deletions

View file

@ -5,11 +5,29 @@ def index
end end
def show def show
id = params.extract_value(:id) #id = params.extract_value(:id)
@category = Category.find_by_id(id)
@forum_topics = @category.forum_topics # @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 end
private
def category_params
params.require(:title, :description)
end end
end

View file

@ -1,10 +1,15 @@
class ForumThreadsController < ApplicationController class ForumThreadsController < ApplicationController
def index def index
@threads = ForumThread.all
end end
def show def show
id = params.extract_value(:id) id = params.extract_value(:id)
@thread = ForumThread.find_by_id(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
end end

View file

@ -1,8 +1,4 @@
class ForumTopicsController < ApplicationController class ForumTopicsController < ApplicationController
def show
id = params.extract_value(:id)
@thread = ForumThread.find_by_id(id)
end
def index def index
@ -10,9 +6,18 @@ def index
end end
def show def show
id = params.extract_value(:id)
@forum_topics = ForumTopic.find_by_id(id) @category = Category.find(params[:category_id])
@threads = ForumThread.all #@forum_topics = ForumTopic.all
@thread = ForumThread.find_by_id(id) #@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
end end
private
def params
params.require(:forum_topic, :title).permit( :description)
end

View file

@ -1,4 +1,8 @@
<section class="threadindex"><% @categories.each do | category | %> <center><h1>SILLYFORUMZ!</h1>
<h3>welcome to the worst forum site on the web <3 </h3>
<hr>
<h2>Forum Categories</h2></center>
<br><section class="threadindex"><% @categories.each do | category | %>
<section class="threadtitle"> <h4><%= category.title %> <%= link_to 'Show', category_path(category) %></h4></section> <section class="threadtitle"> <h4><%= category.title %> <%= link_to 'Show', category_path(category) %></h4></section>
<article><%= category.description %></article><hr> <article><%= category.description %></article><hr>

View file

@ -1,8 +1,8 @@
<section class="threadindex"> <section class="threadindex">
<div class="box"> <div class="box">
<h1><%= @forum_topics.title %></h1> <h1><%= @forum_topic.title %></h1>
<% @threads.each do |thread| %><section class="forumtopic"> <% @forum_threads.each do |forum_thread| %><section class="forumtopic">
<%= thread.title %> <br><%= truncate(@thread.body, length: 200) %> <br></section><br> <%= forum_thread.title %> | <%= link_to 'Show', category_forum_topic_forum_thread_path(@category, @forum_topic, forum_thread) %> <br><%= truncate(forum_thread.body, length: 200) %> <br></section><br>
<% end %> <% end %>
</div> </div>

View file

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