Skip to content

Commit

Permalink
Created Message model and update Rails Version #3
Browse files Browse the repository at this point in the history
  • Loading branch information
BlazeDex committed Mar 5, 2024
1 parent 378b106 commit 67d904c
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.3
3.1.2
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source "https://rubygems.org"

ruby "3.1.3"
ruby "3.1.2"

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.1.3"
Expand Down
5 changes: 5 additions & 0 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Comment < ApplicationRecord
belongs_to :user
belongs_to :post
belongs_to :parent_comment
end
12 changes: 12 additions & 0 deletions db/migrate/20240305013322_create_comments.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CreateComments < ActiveRecord::Migration[7.1]
def change
create_table :comments do |t|
t.text :body
t.references :user, null: false, foreign_key: true
t.references :post, null: false, foreign_key: true
t.references :parent_comment, null: false, foreign_key: { to_table: :comments }

t.timestamps
end
end
end
17 changes: 16 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions test/fixtures/comments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
body: MyText
user: one
post: one
parent_comment: one

two:
body: MyText
user: two
post: two
parent_comment: two
7 changes: 7 additions & 0 deletions test/models/comment_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

class CommentTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

0 comments on commit 67d904c

Please sign in to comment.