From 2586fba3b8a181289c597071733774b3a406f675 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Fri, 6 Jul 2018 15:42:33 -0400 Subject: Abstracted Recordable concern Blogs, streams, and updates are all recordable, and there's no need to repeat code in the models for this. --- app/models/blog.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'app/models/blog.rb') diff --git a/app/models/blog.rb b/app/models/blog.rb index 322a808..5742879 100644 --- a/app/models/blog.rb +++ b/app/models/blog.rb @@ -1,12 +1,10 @@ class Blog < ApplicationRecord - has_many :records, as: :recordable, inverse_of: :recordable + include Recordable validates :title, presence: true validates :body, presence: true, if: :published validates :slug, presence: true, format: /\A[-a-z0-9]+\z/, if: :published - accepts_nested_attributes_for :records, allow_destroy: true - before_validation :set_draft_title before_save :set_published_at -- cgit 1.4.1