Method: Thredded.posts_page_view
- Defined in:
- lib/thredded.rb
.posts_page_view(scope:, current_user:) ⇒ PostsPageView
Returns a view for the given posts’ scope, applying read permission filters to the scope. Can be used in main_app, e.g. for showing the recent user posts on the profile page.
238 239 240 241 242 243 244 245 246 |
# File 'lib/thredded.rb', line 238 def posts_page_view(scope:, current_user:) current_user ||= Thredded::NullUser.new Thredded::PostsPageView.new( current_user, Pundit.policy_scope!(current_user, scope) .where(messageboard_id: Pundit.policy_scope!(current_user, Thredded::Messageboard.all).pluck(:id)) .includes(:postable) ) end |