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 ++++++++++-- app/models/entry.rb | 11 ----------- 2 files changed, 10 insertions(+), 13 deletions(-) delete mode 100644 app/models/entry.rb (limited to 'app/models') 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 diff --git a/app/models/entry.rb b/app/models/entry.rb deleted file mode 100644 index 87fd46d..0000000 --- a/app/models/entry.rb +++ /dev/null @@ -1,11 +0,0 @@ -class Entry < ApplicationRecord - has_many :records, as: :recordable, inverse_of: :recordable - - 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