Move and refactor method from follow to user model to get user interests. Add specification to check the discard of duplicate interests.
This commit is contained in:
@@ -7,7 +7,7 @@ class UsersController < ApplicationController
|
||||
|
||||
def show
|
||||
load_filtered_activity if valid_access?
|
||||
load_interest if valid_interest_access?
|
||||
load_interests if valid_interests_access?
|
||||
end
|
||||
|
||||
private
|
||||
@@ -63,15 +63,15 @@ class UsersController < ApplicationController
|
||||
@budget_investments = Budget::Investment.where(author_id: @user.id).order(created_at: :desc).page(params[:page])
|
||||
end
|
||||
|
||||
def load_interest
|
||||
@interests = Follow.interests_by(@user)
|
||||
def load_interests
|
||||
@user.interests
|
||||
end
|
||||
|
||||
def valid_access?
|
||||
@user.public_activity || authorized_current_user?
|
||||
end
|
||||
|
||||
def valid_interest_access?
|
||||
def valid_interests_access?
|
||||
@user.public_interests || authorized_current_user?
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user