title: list all user's objects
body: <p>as the title says I'm trying to list all cars of one specific user, also each car has two options show and update <img src="https://i.stack.imgur.com/j5ttQ.png" alt="enter image description here"></p>
  
  <p>as you see in the picture, my problem is when I want to show or edit the selected car, it routes (look the bottom left of the image) it takes all the ids of all the cars for example users/"id"/cars/"id1"/"id2" instead to take the id of the specific car: users/"id"/cars/"id1"/
  here is te index.html.erb file:</p>
  
  <pre><code>&lt;div class="container"&gt;
  &lt;h1&gt;Listing Cars&lt;/h1&gt;
  
  &lt;table class="table table-condensed"&gt;
    &lt;tr&gt;
      &lt;th&gt;Brand&lt;/th&gt;
      &lt;th&gt;Color&lt;/th&gt;
      &lt;th&gt;Model&lt;/th&gt;
      &lt;th&gt;Year&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
    &lt;/tr&gt;
  
    &lt;% @car.each do |car| %&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;%= car.brand %&gt;&lt;/td&gt;
        &lt;td&gt;&lt;%= car.color %&gt;&lt;/td&gt;
        &lt;td&gt;&lt;%= car.model %&gt;&lt;/td&gt;
        &lt;td&gt;&lt;%= car.year %&gt;&lt;/td&gt;
        &lt;td&gt;&lt;%= link_to 'Show', user_car_path(@user,@car) %&gt;&lt;/td&gt;
        &lt;td&gt;&lt;%= link_to 'Edit', edit_user_car_path(@user, @car) %&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;% end %&gt;
  &lt;/table&gt;
  &lt;br /&gt;
  &lt;%= link_to 'New car', new_user_car_path, :class =&gt; "btn btn-primary" %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and whether you need the car controller:</p>
  
  <pre><code>class CarsController &lt; ApplicationController
  def new
      @user = User.find(params[:user_id])
      @car = @user.cars.build
  end
  
  def create
      @user = User.find(params[:user_id])
      @car = @user.cars.build(params[:car])
        if @car.save
          redirect_to user_car_path(@user, @car), :flash =&gt; { :notice =&gt; "  car created!" }
        else
          redirect_to new_user_car_path ,:flash =&gt; { :notice =&gt; " sorry try again :(" }
        end
  end
  
  def show
    @user = User.find(params[:user_id])     
    @car = @user.cars.find(params[:id]) 
    #redirect_to user_car_path(@user, @car)  
  end
  def index
    @user = User.find(params[:user_id])     
    @car = @user.cars.all
  end
  def edit
    @user = User.find(params[:user_id])     
    @car = @user.cars.find(params[:id]) 
    #redirect_to user_car_path(@user, @car)  
  end
  def update
  @user = User.find(params[:user_id])  
  @car = @user.cars.find(params[:id])
  if @car.update_attributes(params[:car])
    redirect_to user_cars_path, :flash =&gt; { :notice =&gt; "  Car Updated!" }
  else
    render 'edit'
  end
  end
  end
  </code></pre>