Class: SimpleTeams::RelatedMembersController

Inherits:
BaseController show all
Defined in:
app/controllers/simple_teams/related_members_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#current_ability

Instance Method Details

#indexObject



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/simple_teams/related_members_controller.rb', line 4

def index
  if params[:term].present?
    @members = SimpleTeams.member_class
      .joins(:team_memberships, :teams)
      .where("simple_teams_teams.id" => current_user.teams.pluck(:id))
      .where("email ilike ?", "%#{params[:term]}%")
      .order("#{SimpleTeams.member_class.table_name}.first_name")
      .uniq
    @members.reject! { |member| member.id == current_user.id }
  else
    @members= SimpleTeams.member_class.none
  end
end

#select2Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/simple_teams/related_members_controller.rb', line 18

def select2
  if params[:term].present?
    @members = SimpleTeams.member_class
      .joins(:team_memberships, :teams)
      .where("teams_teams.id" => current_user.teams.pluck(:id))
      .where("email ilike ?", "%#{params[:term]}%")
      .order("#{SimpleTeams.member_class.table_name}.first_name")
      .uniq
    @members.reject! { |member| member.id == current_user.id }
  else
    @members = SimpleTeams.member_class.none
  end
end