1
0
Fork 0

Add attribute Post#published_at

master
Alex Kotov 2 years ago
parent 5828b51ba6
commit 23cf15a705
  1. 4
      app/models/post.rb
  2. 2
      app/views/profiles/show.html.erb
  3. 1
      db/migrate/20210310092955_create_posts.rb
  4. 1
      db/schema.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

@ -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

1
db/schema.rb generated

@ -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