I want to perform a query that selects all users that are "allowed" to interact according to the following method:
User.rb
def allowed?(other_user)
self.friends.include?(other.user) || self.followers.include?(other_user)
end
The problem is that .select { |user| ... } is returning an array, not a collection. How should I write the query correctly so further database queries can be appended (such as limit or order)?
users controller
@user = current_user
@users = User.select { |user| @user.allowed?(user) }
.limit(100)
.order(created_at: :desc)
.paginate(page: params[:page])