fix posts and boards scaffolds

This commit is contained in:
0chan 2023-12-31 02:54:16 +06:00
parent 8cae5955a8
commit b3a2d5a6f4
4 changed files with 21 additions and 3 deletions

View File

@ -1,2 +1,3 @@
class Board < ApplicationRecord
has_many :posts
end

View File

@ -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

View File

@ -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

18
db/schema.rb generated
View File

@ -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