Add attribute Post#published_at
This commit is contained in:
parent
5828b51ba6
commit
23cf15a705
|
@ -1,5 +1,7 @@
|
||||||
class Post < ApplicationRecord
|
class Post < ApplicationRecord
|
||||||
belongs_to :profile
|
belongs_to :profile
|
||||||
|
|
||||||
validates :text, length: { maximum: 200 }
|
validates :text, presence: true, length: { maximum: 200 }
|
||||||
|
|
||||||
|
validates :published_at, presence: true
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
<p class="card-text">
|
<p class="card-text">
|
||||||
<small class="text-muted">
|
<small class="text-muted">
|
||||||
<%= localize post.created_at, format: :short %>
|
<%= localize post.published_at, format: :short %>
|
||||||
</small>
|
</small>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,6 +4,7 @@ class CreatePosts < ActiveRecord::Migration[6.1]
|
||||||
t.timestamps
|
t.timestamps
|
||||||
t.references :profile, null: false, foreign_key: true
|
t.references :profile, null: false, foreign_key: true
|
||||||
t.string :text, null: false
|
t.string :text, null: false
|
||||||
|
t.datetime :published_at, null: false
|
||||||
end
|
end
|
||||||
end
|
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.datetime "updated_at", precision: 6, null: false
|
||||||
t.integer "profile_id", null: false
|
t.integer "profile_id", null: false
|
||||||
t.string "text", null: false
|
t.string "text", null: false
|
||||||
|
t.datetime "published_at", null: false
|
||||||
t.index ["profile_id"], name: "index_posts_on_profile_id"
|
t.index ["profile_id"], name: "index_posts_on_profile_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Reference in New Issue