From 0aace2986a9a7a6d4c84a9ba6819d3df7821e267 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 14 Oct 2023 10:15:24 -0400 Subject: Blogs have an author now --- app/models/blog.rb | 2 ++ app/models/user.rb | 2 ++ 2 files changed, 4 insertions(+) (limited to 'app/models') diff --git a/app/models/blog.rb b/app/models/blog.rb index e640466..e43990e 100644 --- a/app/models/blog.rb +++ b/app/models/blog.rb @@ -4,10 +4,12 @@ class Blog < ApplicationRecord acts_as_taggable has_many :comments + belongs_to :user validates :title, presence: true validates :body, presence: true, if: :published validates :slug, presence: true, format: /\A[-a-z0-9]+\z/, if: :published + validates :user, presence: true before_validation :set_draft_title before_save :set_published_at diff --git a/app/models/user.rb b/app/models/user.rb index 555729a..f9f68fa 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -5,4 +5,6 @@ class User < ApplicationRecord :recoverable, :rememberable, :trackable, :validatable has_secure_token :pokeviewer_token + + has_many :blogs end -- cgit 1.4.1