From 49b11f2864f75bcfb8d0d01439939ed68aa90b8f Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 2 Jul 2018 18:03:37 -0400 Subject: Collapsed Entry -> Blog single-table inheritance to Blog --- app/models/blog.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'app/models/blog.rb') diff --git a/app/models/blog.rb b/app/models/blog.rb index d2b1c27..1ace11b 100644 --- a/app/models/blog.rb +++ b/app/models/blog.rb @@ -1,4 +1,12 @@ -class Blog < Entry +class Blog < ApplicationRecord + has_many :records, as: :recordable, inverse_of: :recordable + validates :title, :body, presence: true -end + validates :slug, presence: true, format: /\A[-a-z0-9]+\z/ + accepts_nested_attributes_for :records, allow_destroy: true + + def path + "/says/#{slug}" + end +end -- cgit 1.4.1