Class: Thredded::Messageboard
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Thredded::Messageboard
- Extended by:
- FriendlyId
- Defined in:
- app/models/thredded/messageboard.rb
Instance Method Summary collapse
- #ensure_position ⇒ Object
-
#last_user ⇒ Object
rubocop:enable Style/Lambda.
- #slug_candidates ⇒ Object
- #update_last_topic! ⇒ Object
Instance Method Details
#ensure_position ⇒ Object
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_user ⇒ Object
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_candidates ⇒ Object
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 |