# Routing Error when testing and using restful routes

**URL:** <https://www.ruby-forum.com/t/routing-error-when-testing-and-using-restful-routes/179987>\
**Category:** Rails\
**Created:** [December 9, 2009, 8:43am UTC](https://www.ruby-forum.com/t/routing-error-when-testing-and-using-restful-routes/179987 "2009-12-09T08:43:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kinunt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/7c8e57/32.png) [@kinunt](https://www.ruby-forum.com/u/kinunt)\
**Post date:** [December 9, 2009, 8:43am UTC](https://www.ruby-forum.com/t/routing-error-when-testing-and-using-restful-routes/179987/1 "2009-12-09T08:43:32Z")

</div>

When testing I get this code I get the following error:

test “should update proveedor” do  
put :update, :id =\> proveedores(:iberdrola).to\_param, :proveedor =\>  
{:fax =\> ‘943456578’}  
assert\_redirected\_to proveedor\_path(assigns(:proveedor))  
end

1. Error:  
test\_should\_update\_proveedor(ProveedoresControllerTest):  
ActionController::RoutingError: proveedor\_url failed to generate from  
{:action=\>“show”, :id=\>nil, :controller=\>“proveedo  
res”}, expected: {:action=\>“show”, :controller=\>“proveedores”}, diff:  
{:id=\>nil}  
(eval):16:in `proveedor_path' /test/functional/proveedores_controller_test.rb:37:in`test\_should\_update\_proveedor’

I have searched the web and I know that the problem is that  
assigns(:proveedor) are not putting the param id that is necessary to  
generate the correct URL, but why? Any idea?

---

<div class="post-metadata">

**Author:** ![kinunt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/7c8e57/32.png) [@kinunt](https://www.ruby-forum.com/u/kinunt)\
**Post date:** [December 9, 2009, 10:44am UTC](https://www.ruby-forum.com/t/routing-error-when-testing-and-using-restful-routes/179987/2 "2009-12-09T10:44:31Z")

</div>

Hi Juan K.

```
 What is in your update action? Can you paste it? I think the id for 

```

proveedor is not setting in update…So the value of id is getting as  
nil. Check assert assigns(:proveedor) also

Sijo

---

<div class="post-metadata">

**Author:** ![kinunt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/7c8e57/32.png) [@kinunt](https://www.ruby-forum.com/u/kinunt)\
**Post date:** [December 9, 2009, 10:45am UTC](https://www.ruby-forum.com/t/routing-error-when-testing-and-using-restful-routes/179987/3 "2009-12-09T10:45:44Z")

</div>

Yes. I found the problem. The problem was that the controller didn’t  
create the proveedor properly and the id were not create properly then.

Thanks!

Sijo k g wrote:

> Hi Juan K.
> 
> ```
> What is in your update action? Can you paste it? I think the id for 
> 
> ```
> 
> proveedor is not setting in update…So the value of id is getting as  
> nil. Check assert assigns(:proveedor) also
