about summary refs log tree commit diff stats
path: root/app/models/stream.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/stream.rb')
-rw-r--r--app/models/stream.rb20
1 files changed, 18 insertions, 2 deletions
diff --git a/app/models/stream.rb b/app/models/stream.rb index 7faa370..6a738e2 100644 --- a/app/models/stream.rb +++ b/app/models/stream.rb
@@ -1,13 +1,29 @@
1class Stream < ApplicationRecord 1class Stream < ApplicationRecord
2 has_many :records, as: :recordable, inverse_of: :recordable 2 include Recordable
3
4 acts_as_taggable
5
3 has_many :updates 6 has_many :updates
4 7
5 validates :title, presence: true 8 validates :title, presence: true
6 validates :slug, presence: true, format: /\A[-a-z0-9]+\z/ 9 validates :slug, presence: true, format: /\A[-a-z0-9]+\z/
7 10
8 accepts_nested_attributes_for :records, allow_destroy: true 11 before_create :set_post_timestamp
9 12
10 def path 13 def path
11 "/thinks/#{slug}" 14 "/thinks/#{slug}"
12 end 15 end
16
17 def to_param
18 slug
19 end
20
21 def taggable
22 self
23 end
24
25 private
26 def set_post_timestamp
27 self.latest_post_at = self.created_at
28 end
13end 29end