Rails 3 route appends _index to route name

It is because your resource is named :planner instead of :planners that Rails decided to add the _index to any collection nested underneath. My guess it is there for readability.

The action named in the collection normally translates to a verb, so I can see why this makes sense. Take the typical photos resource example given in the routing docs:

resources :photos do
  collection do
    get 'search'
  end
end

search_photos GET    /photos/search(.:format)

But if instead we called the resources ‘photo’…

resources :photo do
  collection do
    get 'search'
  end
end

search_photo_index GET    /photo/search(.:format)

In the first case, you search the “photos”, and in the second case you search the “photo index”.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)