about summary refs log tree commit diff stats
path: root/app/models/update.rb
blob: a98a5d4197cbfc64899af0bc6796a7bd6fb15192 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class Update < ApplicationRecord
  include Recordable

  belongs_to :stream

  validates :stream, :body, presence: true

  after_create :set_latest_timestamp

  def path
    "/thinks/#{stream.slug}\#update-#{id}"
  end

  def taggable
    stream
  end

  private
    def set_latest_timestamp
      self.stream.latest_post_at = self.created_at
      self.stream.save!
    end
end