diff --git a/app/models/post.rb b/app/models/post.rb index 7dfe368..f0ad12f 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -1,5 +1,7 @@ class Post < ApplicationRecord belongs_to :profile - validates :text, length: { maximum: 200 } + validates :text, presence: true, length: { maximum: 200 } + + validates :published_at, presence: true end diff --git a/app/views/profiles/show.html.erb b/app/views/profiles/show.html.erb index 6e47773..4a2206f 100644 --- a/app/views/profiles/show.html.erb +++ b/app/views/profiles/show.html.erb @@ -11,7 +11,7 @@

- <%= localize post.created_at, format: :short %> + <%= localize post.published_at, format: :short %>

diff --git a/db/migrate/20210310092955_create_posts.rb b/db/migrate/20210310092955_create_posts.rb index 0b7654c..841048b 100644 --- a/db/migrate/20210310092955_create_posts.rb +++ b/db/migrate/20210310092955_create_posts.rb @@ -4,6 +4,7 @@ class CreatePosts < ActiveRecord::Migration[6.1] t.timestamps t.references :profile, null: false, foreign_key: true t.string :text, null: false + t.datetime :published_at, null: false end end end diff --git a/db/schema.rb b/db/schema.rb index 9664d07..88a396b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -17,6 +17,7 @@ ActiveRecord::Schema.define(version: 2021_03_10_092955) do t.datetime "updated_at", precision: 6, null: false t.integer "profile_id", null: false t.string "text", null: false + t.datetime "published_at", null: false t.index ["profile_id"], name: "index_posts_on_profile_id" end