Class: Thredded::Messageboard
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Thredded::Messageboard
- Extended by:
- FriendlyId
- Defined in:
- app/models/thredded/messageboard.rb
Class Method Summary collapse
-
.friendly_find!(slug_or_id) ⇒ Thredded::Messageboard
Finds the messageboard by its slug or ID, or raises Thredded::Errors::MessageboardNotFound.
Instance Method Summary collapse
- #ensure_position ⇒ Object
- #last_user ⇒ Object
- #normalize_friendly_id(input) ⇒ Object
- #update_last_topic! ⇒ Object
Class Method Details
.friendly_find!(slug_or_id) ⇒ Thredded::Messageboard
Finds the messageboard by its slug or ID, or raises Thredded::Errors::MessageboardNotFound.
91 92 93 94 95 |
# File 'app/models/thredded/messageboard.rb', line 91 def self.friendly_find!(slug_or_id) friendly.find(slug_or_id) rescue ActiveRecord::RecordNotFound raise Thredded::Errors::MessageboardNotFound end |
Instance Method Details
#ensure_position ⇒ Object
27 28 29 |
# File 'app/models/thredded/messageboard.rb', line 27 def ensure_position self.position ||= (created_at || Time.zone.now).to_i end |
#last_user ⇒ Object
97 98 99 |
# File 'app/models/thredded/messageboard.rb', line 97 def last_user last_topic.try(:last_user) end |
#normalize_friendly_id(input) ⇒ Object
107 108 109 |
# File 'app/models/thredded/messageboard.rb', line 107 def normalize_friendly_id(input) Thredded.slugifier.call(input.to_s) end |
#update_last_topic! ⇒ Object
101 102 103 104 105 |
# File 'app/models/thredded/messageboard.rb', line 101 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 |