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:
Senén Rodero Rodríguez
2017-07-07 13:57:07 +02:00
parent a7aef0a9fb
commit 4b2310c135
7 changed files with 33 additions and 29 deletions

View File

@@ -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