From b3a2d5a6f44fa91b477dbb26c6322b8b0466a2c3 Mon Sep 17 00:00:00 2001 From: 0chan <0chan@disroot.org> Date: Sun, 31 Dec 2023 02:54:16 +0600 Subject: [PATCH] fix posts and boards scaffolds --- app/models/board.rb | 1 + app/models/post.rb | 3 +++ db/migrate/20231230205017_create_posts.rb | 2 -- db/schema.rb | 18 +++++++++++++++++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/models/board.rb b/app/models/board.rb index 29e9728..8d52309 100644 --- a/app/models/board.rb +++ b/app/models/board.rb @@ -1,2 +1,3 @@ class Board < ApplicationRecord + has_many :posts end diff --git a/app/models/post.rb b/app/models/post.rb index b2a8b46..5fb103b 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -1,2 +1,5 @@ class Post < ApplicationRecord + belongs_to :board + has_many :replies, class_name: "Post", foreign_key: "parent_id" + belongs_to :parent, class_name: "Post", optional: true end diff --git a/db/migrate/20231230205017_create_posts.rb b/db/migrate/20231230205017_create_posts.rb index a2bad76..56bca8d 100644 --- a/db/migrate/20231230205017_create_posts.rb +++ b/db/migrate/20231230205017_create_posts.rb @@ -10,8 +10,6 @@ class CreatePosts < ActiveRecord::Migration[7.1] t.text :message t.text :message_formatted t.string :password - t.datetime :created_at - t.datetime :updated_at t.datetime :bumped_at t.datetime :deleted_at diff --git a/db/schema.rb b/db/schema.rb index e3d0914..4d627c9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2023_12_30_203445) do +ActiveRecord::Schema[7.1].define(version: 2023_12_30_205017) do create_table "boards", force: :cascade do |t| t.string "slug" t.string "name" @@ -18,4 +18,20 @@ ActiveRecord::Schema[7.1].define(version: 2023_12_30_203445) do t.datetime "updated_at", null: false end + create_table "posts", force: :cascade do |t| + t.integer "board_id" + t.integer "parent_id" + t.integer "visible_id" + t.integer "reply_id" + t.string "name" + t.string "title" + t.text "message" + t.text "message_formatted" + t.string "password" + t.datetime "bumped_at" + t.datetime "deleted_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + end