Add microposts
These will have tags etc. in the future, this is it for now.
This commit is contained in:
parent
2038dd741c
commit
a257e98eb6
|
@ -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
|
|
@ -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
|
|
@ -1,4 +1,4 @@
|
||||||
# one:
|
one:
|
||||||
# record: name_of_fixture (ClassOfFixture)
|
record: some_text (Micropost)
|
||||||
# name: content
|
name: content
|
||||||
# body: <p>In a <i>million</i> stars!</p>
|
body: <p>Just some text</p>
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
some_text:
|
||||||
|
user: gimli
|
|
@ -0,0 +1,7 @@
|
||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
class MicropostTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
Loading…
Reference in New Issue