Class: Hub::Reply

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
SoftDelete, Uid
Defined in:
app/models/hub/reply.rb

Constant Summary collapse

INVALID_CHARS =
%w(                              ).freeze

Instance Method Summary collapse

Methods included from SoftDelete

#deleted?, #destroy

Instance Method Details

#body_content_valid?Boolean

Returns:

  • (Boolean)


35
36
37
38
39
# File 'app/models/hub/reply.rb', line 35

def body_content_valid?
  INVALID_CHARS.all? do |invalid_char|
    body.index(invalid_char).nil?
  end
end

#corrected_body_contentObject



41
42
43
44
45
46
# File 'app/models/hub/reply.rb', line 41

def corrected_body_content
  INVALID_CHARS.each do |invalid_char|
    body.gsub!(invalid_char, '')
  end
  body
end

#update_topic_last_reply_atObject



25
26
27
28
29
30
31
# File 'app/models/hub/reply.rb', line 25

def update_topic_last_reply_at
  return if topic.blank?
  topic.replied_at = Time.current
  topic.last_active_mark = Time.now.to_i
  topic.replies_count = topic.replies.count
  topic.save
end