Class: Thredded::Messageboard

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Defined in:
app/models/thredded/messageboard.rb

Instance Method Summary collapse

Instance Method Details

#ensure_positionObject



26
27
28
# File 'app/models/thredded/messageboard.rb', line 26

def ensure_position
  self.position ||= (created_at || Time.zone.now).to_i
end

#last_userObject

rubocop:enable Style/Lambda



85
86
87
# File 'app/models/thredded/messageboard.rb', line 85

def last_user
  last_topic.try(:last_user)
end

#slug_candidatesObject



89
90
91
92
93
94
# File 'app/models/thredded/messageboard.rb', line 89

def slug_candidates
  [
    :name,
    [:name, '-board']
  ]
end

#update_last_topic!Object



96
97
98
99
100
# File 'app/models/thredded/messageboard.rb', line 96

def update_last_topic!
  return if destroyed?
  self.last_topic = topics.order_recently_posted_first.moderation_state_visible_to_all.first
  save! if last_topic_id_changed?
end