Leem.fin
Leem.fin

Reputation: 42602

Why the path goes to 'show' view not 'index' view

route.rb:

map.resource :car_users

car_users_controller.rb:

class CarUsersController < ApplicationController
  def index
    @car_users = CarUsers.all
  end

  def show
  end
end

I created a link in a view:

link_to "SOMELINK", car_users_path

I thought the car_users_path will invoke the index method of the controller and render the index.html.erb, but it goes to the show.html.erb and invoke the show method in the controller. Why not index?

(I am working with Rails v2.3.2)

Upvotes: 0

Views: 318

Answers (2)

dku.rajkumar
dku.rajkumar

Reputation: 18568

try this

map.car_users '/car_users' :controller =>'car_users'

Upvotes: 0

ramblex
ramblex

Reputation: 3057

I think you're just missing an s

map.resource :car_users

should be

map.resources :car_users

Upvotes: 1

Related Questions