From 42d9db526d3aef2e08848d6bc587feaf3700db42 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 7 Jul 2018 16:23:04 -0400 Subject: Added tags Blogs and streams can now be tagged. Records now show the appropriate tags for an entry. Updates work oddly, because their records show the stream's tags, since updates do not have tags themselves. refs #2 --- app/models/blog.rb | 6 ++++++ app/models/stream.rb | 6 ++++++ app/models/update.rb | 4 ++++ 3 files changed, 16 insertions(+) (limited to 'app/models') diff --git a/app/models/blog.rb b/app/models/blog.rb index 5742879..18f63f1 100644 --- a/app/models/blog.rb +++ b/app/models/blog.rb @@ -1,6 +1,8 @@ class Blog < ApplicationRecord include Recordable + acts_as_taggable + validates :title, presence: true validates :body, presence: true, if: :published validates :slug, presence: true, format: /\A[-a-z0-9]+\z/, if: :published @@ -12,6 +14,10 @@ class Blog < ApplicationRecord "/says/#{slug}" end + def taggable + self + end + private def set_draft_title if self.title.blank? and not self.published diff --git a/app/models/stream.rb b/app/models/stream.rb index 1398b75..0773143 100644 --- a/app/models/stream.rb +++ b/app/models/stream.rb @@ -1,6 +1,8 @@ class Stream < ApplicationRecord include Recordable + acts_as_taggable + has_many :updates validates :title, presence: true @@ -9,4 +11,8 @@ class Stream < ApplicationRecord def path "/thinks/#{slug}" end + + def taggable + self + end end diff --git a/app/models/update.rb b/app/models/update.rb index 73c4911..01907d8 100644 --- a/app/models/update.rb +++ b/app/models/update.rb @@ -8,4 +8,8 @@ class Update < ApplicationRecord def path "/thinks/#{stream.slug}\#update-#{id}" end + + def taggable + stream + end end -- cgit 1.4.1