Resource routing error with the route equipment/new

I'm having an issue with resource routing after running a "ruby
script/generate scaffold equipment" command. I did not make any changes
to the equipment model/controller/views after running this.

The full command I ran (all one line) ...

ruby script/generate scaffold equipment
name:string description:text contact:text keywords:string
created_at:datetime created_by:integer
updated_at:datetime updated_by:integer

IN config/routes.rb I have the following placed above the default routes
...

map.resources :equipment

David Piehler wrote:

I'm having an issue with resource routing after running a "ruby
script/generate scaffold equipment" command. I did not make any changes
to the equipment model/controller/views after running this.

The following route fails ...
/equipment/new

When going to /equipment/new ...

ActionController::RoutingError in Equipment#new
Showing equipment/new.html.erb where line #5 raised:
equipment_url failed to generate from {:controller=>"equipment",
:action=>"show"} - you may have ambiguous routes, or you may need to
supply additional parameters for this route. content_url has the
following required parameters: ["equipment", :id] - are they all
satisfied?

Extracted source (around line #5):
2:
3: <%= error_messages_for :equipment %>
4:
5: <% form_for(@equipment) do |f| %>
6: <p>
7: <b>Name</b><br />
8: <%= f.text_field :name %>

Running "rake routes" showed something odd. Instead of "equipment", the
plain GET route is shown as "equipment_index". Is there any way to
override/fix this?

          equipment_index GET /equipment
{:action=>"index", :controller=>"equipment"}
formatted_equipment_index GET /equipment.:format
{:action=>"index", :controller=>"equipment"}
                          POST /equipment
{:action=>"create", :controller=>"equipment"}
                          POST /equipment.:format
{:action=>"create", :controller=>"equipment"}
            new_equipment GET /equipment/new
{:action=>"new", :controller=>"equipment"}
  formatted_new_equipment GET /equipment/new.:format
{:action=>"new", :controller=>"equipment"}
           edit_equipment GET /equipment/:id/edit
{:action=>"edit", :controller=>"equipment"}
formatted_edit_equipment GET /equipment/:id/edit.:format
{:action=>"edit", :controller=>"equipment"}
                equipment GET /equipment/:id
{:action=>"show", :controller=>"equipment"}
      formatted_equipment GET /equipment/:id.:format
{:action=>"show", :controller=>"equipment"}
                          PUT /equipment/:id
{:action=>"update", :controller=>"equipment"}
                          PUT /equipment/:id.:format
{:action=>"update", :controller=>"equipment"}
                          DELETE /equipment/:id
{:action=>"destroy", :controller=>"equipment"}
                          DELETE /equipment/:id.:format
{:action=>"destroy", :controller=>"equipment"}
               facilities GET /facilities
{:action=>"index", :controller=>"facilities"}
     formatted_facilities GET /facilities.:format
{:action=>"index", :controller=>"facilities"}
                          POST /facilities
{:action=>"create", :controller=>"facilities"}
                          POST /facilities.:format
{:action=>"create", :controller=>"facilities"}
             new_facility GET /facilities/new
{:action=>"new", :controller=>"facilities"}
   formatted_new_facility GET /facilities/new.:format
{:action=>"new", :controller=>"facilities"}
            edit_facility GET /facilities/:id/edit
{:action=>"edit", :controller=>"facilities"}
  formatted_edit_facility GET /facilities/:id/edit.:format
{:action=>"edit", :controller=>"facilities"}
                 facility GET /facilities/:id
{:action=>"show", :controller=>"facilities"}
       formatted_facility GET /facilities/:id.:format
{:action=>"show", :controller=>"facilities"}
                          PUT /facilities/:id
{:action=>"update", :controller=>"facilities"}
                          PUT /facilities/:id.:format
{:action=>"update", :controller=>"facilities"}
                          DELETE /facilities/:id
{:action=>"destroy", :controller=>"facilities"}
                          DELETE /facilities/:id.:format
{:action=>"destroy", :controller=>"facilities"}
                                 /:controller/:action/:id
                                 /:controller/:action/:id.:format

Thanks,
- Dave

David Piehler wrote:

Running "rake routes" showed something odd. Instead of "equipment", the
plain GET route is shown as "equipment_index". Is there any way to
override/fix this?

Nevermind, it has to be 'equipment_index' because the plain 'equipment'
is being used by the 'show' action.

And now my first lesson in named resource routes is complete :slight_smile: