Add attribute Post#published_at
This commit is contained in:
parent
5828b51ba6
commit
23cf15a705
|
@ -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
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
<p class="card-text">
|
||||
<small class="text-muted">
|
||||
<%= localize post.created_at, format: :short %>
|
||||
<%= localize post.published_at, format: :short %>
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Reference in New Issue