your comment on line 11:
"For example, this controller is called via URL like

/teams/3/users/4

because you write route definition in routes.rb

resources :teams do
  resources :users
end

Therefor you should find a user instance from DB as below

@team = Team.find params[:team_id]
@user = @team.users.find params[:id]

When User that has id with 2 exists and it has team_id with 3, "GET /teams/2/users/2" should return Not Found Exception.
Your code returns user instance with id=2. Why did you make users resource children of teams resource?
" And I replace "@user = User.find params[:id]" by 
@team = Team.find params[:team_id]
@user = @team.users.find params[:id]