# Resource routing error with the route equipment/new

**URL:** <https://www.ruby-forum.com/t/resource-routing-error-with-the-route-equipment-new/138986>\
**Category:** Rails\
**Created:** [May 29, 2008, 7:31pm UTC](https://www.ruby-forum.com/t/resource-routing-error-with-the-route-equipment-new/138986 "2008-05-29T19:31:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dpitman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9adbd/32.png) [@dpitman](https://www.ruby-forum.com/u/dpitman)\
**Post date:** [May 29, 2008, 7:31pm UTC](https://www.ruby-forum.com/t/resource-routing-error-with-the-route-equipment-new/138986/1 "2008-05-29T19:31:24Z")

</div>

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

–

The following routes work (I added ID#1 directly into the database) …  
/equipment  
/equipment/1  
/equipment/1/edit

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:

7: **Name**  
  
8: \<%= f.text\_field :name %\>

–

I’ve tried adding the following to inflections.rb (one at a time, not  
simultaneously) even though I think ‘equipment’ is already in the  
standard rails inflections code, and nothing changed …

Inflector.inflections do |inflect|  
inflect.uncountable %w( equipment )  
end

Inflector.inflections do |inflect|  
inflect.irregular ‘equipment’, ‘equipment’  
end

–

I also tried changing routes.rb to the following, which caused  
equipment/new to work but the other three routes to fail …

map.resources :equipment, :singular =\> :equipment\_instance

–

Any ideas on what could be happening?

THANKS!

- Dave

---

<div class="post-metadata">

**Author:** ![dpitman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9adbd/32.png) [@dpitman](https://www.ruby-forum.com/u/dpitman)\
**Post date:** [May 29, 2008, 8:49pm UTC](https://www.ruby-forum.com/t/resource-routing-error-with-the-route-equipment-new/138986/2 "2008-05-29T20:49:18Z")

</div>

David P. 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:
> 
> 7: **Name**  
>   
> 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

---

<div class="post-metadata">

**Author:** ![dpitman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9adbd/32.png) [@dpitman](https://www.ruby-forum.com/u/dpitman)\
**Post date:** [May 29, 2008, 11:50pm UTC](https://www.ruby-forum.com/t/resource-routing-error-with-the-route-equipment-new/138986/3 "2008-05-29T23:50:43Z")

</div>

David P. 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 🙂

---

<div class="post-metadata">

**Author:** ![dpitman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9adbd/32.png) [@dpitman](https://www.ruby-forum.com/u/dpitman)\
**Post date:** [February 19, 2009, 7:49pm UTC](https://www.ruby-forum.com/t/resource-routing-error-with-the-route-equipment-new/138986/4 "2009-02-19T19:49:35Z")

</div>

David,  
I am having the same issue. Do you mind providing the code you used to  
fix this issue?

Thanks,  
John

On 29 May 2008, 15:50, David P. \<rails-mailing-l…@andreas-
