Re: rspec_scaffold URL generation errors

Robert Walker
Tue, 22 Sep 2009 14:13:23 -0000

> 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) %>