models: refactor search visibility methods.
Refactor how model visibility works in index actions: * Call `visible` in the controller instead of in model `search` methods. This decouples model visibility from model searching. * Explicitly pass CurrentUser when calling `visible`. This reduces hidden dependencies on the current user inside models. * Standardize on calling the method `visible`. In some places it was called `permitted` instead. * Add a `visible` base method to ApplicationModel.
This commit is contained in:
@@ -3,7 +3,7 @@ class ForumPostVotesController < ApplicationController
|
||||
before_action :member_only, only: [:create, :destroy]
|
||||
|
||||
def index
|
||||
@forum_post_votes = ForumPostVote.visible.paginated_search(params, count_pages: true)
|
||||
@forum_post_votes = ForumPostVote.visible(CurrentUser.user).paginated_search(params, count_pages: true)
|
||||
@forum_post_votes = @forum_post_votes.includes(:creator, forum_post: [:creator, :topic]) if request.format.html?
|
||||
|
||||
respond_with(@forum_post_votes)
|
||||
|
||||
Reference in New Issue
Block a user