Class: Thredded::PrivatePost
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Thredded::PrivatePost
- Includes:
- PostCommon
- Defined in:
- app/models/thredded/private_post.rb
Class Method Summary collapse
-
.find!(id) ⇒ Thredded::PrivatePost
Finds the post by its ID, or raises Errors::PrivatePostNotFound.
Instance Method Summary collapse
- #page(per_page: self.class.default_per_page) ⇒ Object
- #private_topic_post? ⇒ Boolean
-
#readers ⇒ ActiveRecord::Relation<Thredded.user_class>
Users that can read this post.
Methods included from PostCommon
#avatar_url, #calculate_page, #filtered_content, #first_post_in_topic?, #mark_as_unread, #previous_post
Class Method Details
.find!(id) ⇒ Thredded::PrivatePost
Finds the post by its ID, or raises Errors::PrivatePostNotFound.
28 29 30 |
# File 'app/models/thredded/private_post.rb', line 28 def self.find!(id) find_by(id: id) || fail(Thredded::Errors::PrivatePostNotFound) end |
Instance Method Details
#page(per_page: self.class.default_per_page) ⇒ Object
33 34 35 |
# File 'app/models/thredded/private_post.rb', line 33 def page(per_page: self.class.default_per_page) calculate_page(postable.posts, per_page) end |
#private_topic_post? ⇒ Boolean
37 38 39 |
# File 'app/models/thredded/private_post.rb', line 37 def private_topic_post? true end |
#readers ⇒ ActiveRecord::Relation<Thredded.user_class>
Returns users that can read this post.
42 43 44 45 46 47 48 49 |
# File 'app/models/thredded/private_post.rb', line 42 def readers collection_proxy = postable.users if persisted? collection_proxy.scope else Thredded.user_class.where(id: collection_proxy.to_a.map(&:id)) end end |