Class: QATopic

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
QA_Rails::ContentMarkdownCache
Defined in:
app/models/qa_topic.rb

Instance Method Summary collapse

Methods included from QA_Rails::ContentMarkdownCache

#_content_markdown_cache

Instance Method Details

#_last_replyObject



16
17
18
# File 'app/models/qa_topic.rb', line 16

def _last_reply
  self.replies.last || {}
end

#last_reply(reload = false) ⇒ Object

TODO expire from list if reply is delete



10
11
12
13
14
15
# File 'app/models/qa_topic.rb', line 10

def last_reply reload = false
  _r = Rails.cache.fetch self.last_reply_cache_key do
    _last_reply.to_json
  end
  JSON.parse(_r)
end

#last_reply_cache_keyObject



20
# File 'app/models/qa_topic.rb', line 20

def last_reply_cache_key; "qa:topic_#{self.id}:last_reply" end

#tObject



21
# File 'app/models/qa_topic.rb', line 21

def t; self.created_at.strftime("%Y%m%d-%H%M%S") end