Class: QATopic
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- QATopic
- Includes:
- QA_Rails::ContentMarkdownCache
- Defined in:
- app/models/qa_topic.rb
Instance Method Summary collapse
- #_last_reply ⇒ Object
-
#last_reply(reload = false) ⇒ Object
TODO expire from list if reply is delete.
- #last_reply_cache_key ⇒ Object
- #t ⇒ Object
Methods included from QA_Rails::ContentMarkdownCache
Instance Method Details
#_last_reply ⇒ Object
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_key ⇒ Object
20 |
# File 'app/models/qa_topic.rb', line 20 def last_reply_cache_key; "qa:topic_#{self.id}:last_reply" end |
#t ⇒ Object
21 |
# File 'app/models/qa_topic.rb', line 21 def t; self.created_at.strftime("%Y%m%d-%H%M%S") end |