# Rspec\_scaffold URL generation errors

**URL:** <https://www.ruby-forum.com/t/rspec-scaffold-url-generation-errors/175899>\
**Category:** Rails\
**Created:** [September 22, 2009, 3:02pm UTC](https://www.ruby-forum.com/t/rspec-scaffold-url-generation-errors/175899 "2009-09-22T15:02:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![comtux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c57346/32.png) [@comtux](https://www.ruby-forum.com/u/comtux)\
**Post date:** [September 22, 2009, 3:02pm UTC](https://www.ruby-forum.com/t/rspec-scaffold-url-generation-errors/175899/1 "2009-09-22T15:02:03Z")

</div>

I am using Rails 2.3.4 and when I use rspec\_scaffold the code that is  
generated does not work without modification. For example, the link\_to  
that is generated for a show

\<%= link\_to 'Show', invoice\_payment %\>

fails with “invoice\_payment\_url failed to generate from  
{:format=\>#\<InvoicePayment id: 1, …”

but if I change the code to

\<%= link\_to 'Show', :id =\> invoice\_payment %\> it works fine. This seems inconsistent with the documentation.

What am I doing wrong here?

---

<div class="post-metadata">

**Author:** ![comtux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c57346/32.png) [@comtux](https://www.ruby-forum.com/u/comtux)\
**Post date:** [September 22, 2009, 4:13pm UTC](https://www.ruby-forum.com/t/rspec-scaffold-url-generation-errors/175899/2 "2009-09-22T16:13:23Z")

</div>

Steve Scruggs wrote:

> I am using Rails 2.3.4 and when I use rspec\_scaffold the code that is  
> generated does not work without modification. For example, the link\_to  
> that is generated for a show
> 
> \<%= link\_to 'Show', invoice\_payment %\>
> 
> fails with “invoice\_payment\_url failed to generate from  
> {:format=\>#\<InvoicePayment id: 1, …”

Judging from this error. It appears to me that you have a problem with  
your routing. It appears to be trying to take the invoice\_payment object  
as the :format for the URL, which would not be correct. Make sure that  
you don’t have a route in your routes.rb file that is interfering with  
the resource routing.

> but if I change the code to
> 
> \<%= link\_to 'Show', :id =\> invoice\_payment %\> it works fine. This seems inconsistent with the documentation.

This work, but is bizarre syntax. You’re forcing the invoice\_payment.id  
into the :id parameter making it work, but the “proper” syntax when not  
using the shortcut syntax would be:

\<%= link\_to 'Show', invoice\_payment\_path(invoice\_payment) %\>

---

<div class="post-metadata">

**Author:** ![comtux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c57346/32.png) [@comtux](https://www.ruby-forum.com/u/comtux)\
**Post date:** [September 22, 2009, 4:27pm UTC](https://www.ruby-forum.com/t/rspec-scaffold-url-generation-errors/175899/3 "2009-09-22T16:27:42Z")

</div>

Robert W. wrote:

> Steve Scruggs wrote:
> 
> > I am using Rails 2.3.4 and when I use rspec\_scaffold the code that is  
> > generated does not work without modification. For example, the link\_to  
> > that is generated for a show
> > 
> > \<%= link\_to 'Show', invoice\_payment %\>
> > 
> > fails with “invoice\_payment\_url failed to generate from  
> > {:format=\>#\<InvoicePayment id: 1, …”
> 
> Judging from this error. It appears to me that you have a problem with  
> your routing. It appears to be trying to take the invoice\_payment object  
> as the :format for the URL, which would not be correct. Make sure that  
> you don’t have a route in your routes.rb file that is interfering with  
> the resource routing.
> 
> > but if I change the code to
> > 
> > \<%= link\_to 'Show', :id =\> invoice\_payment %\> it works fine. This seems inconsistent with the documentation.
> 
> This work, but is bizarre syntax. You’re forcing the invoice\_payment.id  
> into the :id parameter making it work, but the “proper” syntax when not  
> using the shortcut syntax would be:
> 
> \<%= link\_to 'Show', invoice\_payment\_path(invoice\_payment) %\>

Thanks for the quick reply Robert. The syntax that you suggest gives  
the same error. The routes.rb file has the following as the first item.  
map.resources :invoice\_payments

Any other ideas where the issue may be?

---

<div class="post-metadata">

**Author:** ![comtux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c57346/32.png) [@comtux](https://www.ruby-forum.com/u/comtux)\
**Post date:** [September 22, 2009, 5:06pm UTC](https://www.ruby-forum.com/t/rspec-scaffold-url-generation-errors/175899/4 "2009-09-22T17:06:09Z")

</div>

Steve Scruggs wrote:  
[…]

> Thanks for the quick reply Robert. The syntax that you suggest gives  
> the same error.

Of course. You must fix your routing, I think.

> The routes.rb file has the following as the first item.  
> map.resources :invoice\_payments

That should be OK. How’s your output from “rake routes”?

> Any other ideas where the issue may be?

Have you restarted your server since putting that line in the routes  
file? (If you’re using Rails in development mode, this is probably not  
the issue, but it’s quick and easy to try.)

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![comtux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c57346/32.png) [@comtux](https://www.ruby-forum.com/u/comtux)\
**Post date:** [September 23, 2009, 3:33pm UTC](https://www.ruby-forum.com/t/rspec-scaffold-url-generation-errors/175899/5 "2009-09-23T15:33:20Z")

</div>

Steve Scruggs wrote:

The problem was caused by the plugin resource\_fu. I removed the plugin  
and the url’s are now generated as expected.

---

<div class="post-metadata">

**Author:** ![comtux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c57346/32.png) [@comtux](https://www.ruby-forum.com/u/comtux)\
**Post date:** [September 22, 2009, 5:27pm UTC](https://www.ruby-forum.com/t/rspec-scaffold-url-generation-errors/175899/6 "2009-09-22T17:27:25Z")

</div>

Marnen Laibow-Koser wrote:

> Steve Scruggs wrote:  
> […]
> 
> > Thanks for the quick reply Robert. The syntax that you suggest gives  
> > the same error.
> 
> Of course. You must fix your routing, I think.
> 
> > The routes.rb file has the following as the first item.  
> > map.resources :invoice\_payments
> 
> That should be OK. How’s your output from “rake routes”?
> 
> > Any other ideas where the issue may be?
> 
> Have you restarted your server since putting that line in the routes  
> file? (If you’re using Rails in development mode, this is probably not  
> the issue, but it’s quick and easy to try.)
> 
> ## Best,
> 
> Marnen Laibow-Koser  
> [http://www.marnen.org](http://www.marnen.org)  
> removed\_email\_address@domain.invalid  
> I have restarted the server many times, below is the rake routes output  
> /tuneup  
> {:action=\>“show”, :controller=\>“tuneup”}  
> /tuneup/:action  
> {:controller=\>“tuneup”}  
> invoice\_payments GET /invoice\_payments(.:format)  
> {:action=\>“index”, :controller=\>“invoice\_payments”}  
> POST /invoice\_payments(.:format)  
> {:action=\>“create”, :controller=\>“invoice\_payments”}  
> new\_invoice\_payment GET /invoice\_payments/new(.:format)  
> {:action=\>“new”, :controller=\>“invoice\_payments”}  
> edit\_invoice\_payment GET /invoice\_payments/:id/edit(.:format)  
> {:action=\>“edit”, :controller=\>“invoice\_payments”}  
> invoice\_payment GET /invoice\_payments/:id(.:format)  
> {:action=\>“show”, :controller=\>“invoice\_payments”}  
> PUT /invoice\_payments/:id(.:format)  
> {:action=\>“update”, :controller=\>“invoice\_payments”}  
> DELETE /invoice\_payments/:id(.:format)  
> {:action=\>“destroy”, :controller=\>“invoice\_payments”}  
> decline\_offers GET /decline\_offers(.:format)  
> {:action=\>“index”, :controller=\>“decline\_offers”}  
> POST /decline\_offers(.:format)  
> {:action=\>“create”, :controller=\>“decline\_offers”}  
> new\_decline\_offer GET /decline\_offers/new(.:format)  
> {:action=\>“new”, :controller=\>“decline\_offers”}  
> edit\_decline\_offer GET /decline\_offers/:id/edit(.:format)  
> {:action=\>“edit”, :controller=\>“decline\_offers”}  
> decline\_offer GET /decline\_offers/:id(.:format)  
> {:action=\>“show”, :controller=\>“decline\_offers”}  
> PUT /decline\_offers/:id(.:format)  
> {:action=\>“update”, :controller=\>“decline\_offers”}  
> DELETE /decline\_offers/:id(.:format)  
> {:action=\>“destroy”, :controller=\>“decline\_offers”}  
> accept\_job\_offers GET /accept\_job\_offers(.:format)  
> {:action=\>“index”, :controller=\>“accept\_job\_offers”}  
> POST /accept\_job\_offers(.:format)  
> {:action=\>“create”, :controller=\>“accept\_job\_offers”}  
> new\_accept\_job\_offer GET /accept\_job\_offers/new(.:format)  
> {:action=\>“new”, :controller=\>“accept\_job\_offers”}  
> edit\_accept\_job\_offer GET /accept\_job\_offers/:id/edit(.:format)  
> {:action=\>“edit”, :controller=\>“accept\_job\_offers”}  
> accept\_job\_offer GET /accept\_job\_offers/:id(.:format)  
> {:action=\>“show”, :controller=\>“accept\_job\_offers”}  
> PUT /accept\_job\_offers/:id(.:format)  
> {:action=\>“update”, :controller=\>“accept\_job\_offers”}  
> DELETE /accept\_job\_offers/:id(.:format)  
> {:action=\>“destroy”, :controller=\>“accept\_job\_offers”}  
> projects GET /projects(.:format)  
> {:action=\>“index”, :controller=\>“projects”}  
> POST /projects(.:format)  
> {:action=\>“create”, :controller=\>“projects”}  
> new\_project GET /projects/new(.:format)  
> {:action=\>“new”, :controller=\>“projects”}  
> edit\_project GET /projects/:id/edit(.:format)  
> {:action=\>“edit”, :controller=\>“projects”}  
> project GET /projects/:id(.:format)  
> {:action=\>“show”, :controller=\>“projects”}  
> PUT /projects/:id(.:format)  
> {:action=\>“update”, :controller=\>“projects”}  
> DELETE /projects/:id(.:format)  
> {:action=\>“destroy”, :controller=\>“projects”}  
> project\_assignments GET /project\_assignments(.:format)  
> {:action=\>“index”, :controller=\>“project\_assignments”}  
> POST /project\_assignments(.:format)  
> {:action=\>“create”, :controller=\>“project\_assignments”}  
> new\_project\_assignment GET /project\_assignments/new(.:format)  
> {:action=\>“new”, :controller=\>“project\_assignments”}  
> edit\_project\_assignment GET /project\_assignments/:id/edit(.:format)  
> {:action=\>“edit”, :controller=\>“project\_assignments”}  
> project\_assignment GET /project\_assignments/:id(.:format)  
> {:action=\>“show”, :controller=\>“project\_assignments”}  
> PUT /project\_assignments/:id(.:format)  
> {:action=\>“update”, :controller=\>“project\_assignments”}  
> DELETE /project\_assignments/:id(.:format)  
> {:action=\>“destroy”, :controller=\>“project\_assignments”}  
> new\_session GET /session/new(.:format)  
> {:action=\>“new”, :controller=\>“sessions”}  
> edit\_session GET /session/edit(.:format)  
> {:action=\>“edit”, :controller=\>“sessions”}  
> session GET /session(.:format)  
> {:action=\>“show”, :controller=\>“sessions”}  
> PUT /session(.:format)  
> {:action=\>“update”, :controller=\>“sessions”}  
> DELETE /session(.:format)  
> {:action=\>“destroy”, :controller=\>“sessions”}  
> POST /session(.:format)  
> {:action=\>“create”, :controller=\>“sessions”}  
> users GET /users(.:format)  
> {:action=\>“index”, :controller=\>“users”}  
> POST /users(.:format)  
> {:action=\>“create”, :controller=\>“users”}  
> new\_user GET /users/new(.:format)  
> {:action=\>“new”, :controller=\>“users”}  
> edit\_user GET /users/:id/edit(.:format)  
> {:action=\>“edit”, :controller=\>“users”}  
> edit\_password\_user GET /users/:id/edit\_password(.:format)  
> {:action=\>“edit\_password”, :controller=\>“users”}  
> user GET /users/:id(.:format)  
> {:action=\>“show”, :controller=\>“users”}  
> PUT /users/:id(.:format)  
> {:action=\>“update”, :controller=\>“users”}  
> DELETE /users/:id(.:format)  
> {:action=\>“destroy”, :controller=\>“users”}  
> user\_assets GET /users/:user\_id/assets(.:format)  
> {:action=\>“index”, :controller=\>“assets”}  
> POST /users/:user\_id/assets(.:format)  
> {:action=\>“create”, :controller=\>“assets”}  
> new\_user\_asset GET /users/:user\_id/assets/new(.:format)  
> {:action=\>“new”, :controller=\>“assets”}  
> edit\_user\_asset GET /users/:user\_id/assets/:id/edit(.:format)  
> {:action=\>“edit”, :controller=\>“assets”}  
> user\_asset GET /users/:user\_id/assets/:id(.:format)  
> {:action=\>“show”, :controller=\>“assets”}  
> PUT /users/:user\_id/assets/:id(.:format)  
> {:action=\>“update”, :controller=\>“assets”}  
> DELETE /users/:user\_id/assets/:id(.:format)  
> {:action=\>“destroy”, :controller=\>“assets”}  
> list\_companies GET /companies/list(.:format)  
> {:action=\>“list”, :controller=\>“companies”}  
> companies GET /companies(.:format)  
> {:action=\>“index”, :controller=\>“companies”}  
> POST /companies(.:format)  
> {:action=\>“create”, :controller=\>“companies”}  
> new\_company GET /companies/new(.:format)  
> {:action=\>“new”, :controller=\>“companies”}  
> edit\_company GET /companies/:id/edit(.:format)  
> {:action=\>“edit”, :controller=\>“companies”}  
> company GET /companies/:id(.:format)  
> {:action=\>“show”, :controller=\>“companies”}  
> PUT /companies/:id(.:format)  
> {:action=\>“update”, :controller=\>“companies”}  
> DELETE /companies/:id(.:format)  
> {:action=\>“destroy”, :controller=\>“companies”}  
> company\_assets GET /companies/:company\_id/assets(.:format)  
> {:action=\>“index”, :controller=\>“assets”}  
> POST /companies/:company\_id/assets(.:format)  
> {:action=\>“create”, :controller=\>“assets”}  
> new\_company\_asset GET  
> /companies/:company\_id/assets/new(.:format) {:action=\>“new”,  
> :controller=\>“assets”}  
> edit\_company\_asset GET  
> /companies/:company\_id/assets/:id/edit(.:format) {:action=\>“edit”,  
> :controller=\>“assets”}  
> pictures\_company\_asset GET  
> /companies/:company\_id/assets/:id/pictures(.:format)  
> {:action=\>“pictures”, :controller=\>“assets”}  
> company\_asset GET  
> /companies/:company\_id/assets/:id(.:format) {:action=\>“show”,  
> :controller=\>“assets”}  
> PUT  
> /companies/:company\_id/assets/:id(.:format) {:action=\>“update”,  
> :controller=\>“assets”}  
> DELETE  
> /companies/:company\_id/assets/:id(.:format)  
> {:action=\>“destroy”, :controller=\>“assets”}  
> /:controller/service.wsdl  
> {:action=\>“wsdl”}  
> /  
> {:action=\>“index”, :controller=\>“home”}  
> /confirm\_email/:hash  
> {:action=\>“confirm\_email”, :controller=\>“join”}  
> /logoff  
> {:action=\>“destroy”, :controller=\>“sessions”}  
> /no\_permissions  
> {:action=\>“no\_permissions”, :controller=\>“users”}  
> /users/edit\_employer\_profile  
> {:action=\>“edit\_employer\_profile”, :controller=\>“users”}  
> /users/update  
> {:action=\>“update”, :controller=\>“users”}  
> /my\_hires  
> {:action=\>“my\_hires”, :controller=\>“accept\_job\_offers”}  
> /list\_my\_project\_assignments  
> {:action=\>“list\_my\_project\_assignments”,  
> :controller=\>“project\_assignments”}  
> /list\_projects\_assigned\_to\_me  
> {:action=\>“list\_projects\_assigned\_to\_me”,  
> :controller=\>“project\_assignments”}  
> /swap\_picture  
> {:action=\>“swap\_picture”, :controller=\>“user\_assets”}  
> /swap\_video  
> {:action=\>“swap\_video”, :controller=\>“user\_assets”}  
> /:controller  
> {:action=\>“index”}  
> /:controller/:action  
> /:controller/:action/:id  
> /:controller/:action/:id(.:format)
