Wow, that was difficult. I knew I needed to make an ajax request, so I included the route. Then, through errors, realized I needed a controller. But then I couldn't seem to find get the Users#index to work. I tried to find the team by Team.find(params[:id]), but that didn't work. Finally, this worked:
def index
team_id = params[:team_id]
if team_id
@users = User.includes(:teams).where(teams: {id: team_id})
else
@users = User.all
end
end
Wow, that was difficult. I knew I needed to make an ajax request, so I included the route. Then, through errors, realized I needed a controller. But then I couldn't seem to find get the Users#index to work. I tried to find the team by Team.find(params[:id]), but that didn't work. Finally, this worked: