Class: Thredded::Post
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Thredded::Post
- Includes:
- ContentModerationState, PostCommon
- Defined in:
- app/models/thredded/post.rb
Class Method Summary collapse
-
.find!(id) ⇒ Thredded::Post
Finds the post by its ID, or raises Errors::PostNotFound.
Instance Method Summary collapse
- #page(per_page: self.class.default_per_page, user:) ⇒ Object
- #private_topic_post? ⇒ Boolean
-
#readers ⇒ ActiveRecord::Relation<Thredded.user_class>
Users that can read this post.
Methods included from ContentModerationState
#moderation_state_visible_to_all?, #moderation_state_visible_to_user?
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::Post
Finds the post by its ID, or raises Errors::PostNotFound.
48 49 50 |
# File 'app/models/thredded/post.rb', line 48 def self.find!(id) find_by(id: id) || fail(Thredded::Errors::PostNotFound) end |
Instance Method Details
#page(per_page: self.class.default_per_page, user:) ⇒ Object
54 55 56 57 |
# File 'app/models/thredded/post.rb', line 54 def page(per_page: self.class.default_per_page, user:) readable_posts = PostPolicy::Scope.new(user, postable.posts).resolve calculate_page(readable_posts, per_page) end |
#private_topic_post? ⇒ Boolean
59 60 61 |
# File 'app/models/thredded/post.rb', line 59 def private_topic_post? false end |
#readers ⇒ ActiveRecord::Relation<Thredded.user_class>
Returns users that can read this post.
64 65 66 |
# File 'app/models/thredded/post.rb', line 64 def readers Thredded.user_class.([]) end |