Add microposts

These will have tags etc. in the future, this is it for now.
This commit is contained in:
Trevor Vallender 2023-09-17 12:45:24 +01:00
parent 2038dd741c
commit a257e98eb6
5 changed files with 31 additions and 4 deletions

9
app/models/micropost.rb Normal file
View File

@ -0,0 +1,9 @@
# frozen_string_literal: true
class Micropost < ApplicationRecord
belongs_to :user
has_rich_text :content
validates :user, presence: true
validates :content, presence: true
end

View File

@ -0,0 +1,9 @@
class CreateMicroposts < ActiveRecord::Migration[7.0]
def change
create_table :microposts do |t|
t.references :user, null: false, foreign_key: true
t.timestamps
end
end
end

View File

@ -1,4 +1,4 @@
# one:
# record: name_of_fixture (ClassOfFixture)
# name: content
# body: <p>In a <i>million</i> stars!</p>
one:
record: some_text (Micropost)
name: content
body: <p>Just some text</p>

2
test/fixtures/microposts.yml vendored Normal file
View File

@ -0,0 +1,2 @@
some_text:
user: gimli

View File

@ -0,0 +1,7 @@
require "test_helper"
class MicropostTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end