# Foxy Fixtures and Polymorphism not running properly

**URL:** <https://www.ruby-forum.com/t/foxy-fixtures-and-polymorphism-not-running-properly/173817>\
**Category:** Rails\
**Created:** [August 15, 2009, 8:20pm UTC](https://www.ruby-forum.com/t/foxy-fixtures-and-polymorphism-not-running-properly/173817 "2009-08-15T20:20:50Z")\
**Posts on this page:** 1\
**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:** [August 15, 2009, 8:20pm UTC](https://www.ruby-forum.com/t/foxy-fixtures-and-polymorphism-not-running-properly/173817/1 "2009-08-15T20:20:50Z")

</div>

I would like to hear ideas about a problem I’m having with testing a  
controller from a model that uses polimorphism. It seems that the  
fixture do not recognize the relationship. Did you see errors in these  
files? The error I get is:

/\*\*\*\*\* ERROR \*\*\*\*\*/

1. Error:  
test\_should\_show\_ingreso(IngresosControllerTest):  
ActionView::TemplateError: You have a nil object when you didn’t expect  
it!  
The error occurred while evaluating nil.nombre  
On line #18 of app/views/ingresos/show.html.erb

/\*\*\*\*\* clientes.yml \*\*\*\*\*/  
jack:  
NIF: B98654321  
nombre: Jack

/\*\*\*\*\* ingresos.yml \*\*\*\*\*/  
primero:  
origen: jack (Cliente)

/\*\*\*\*\* cliente.rb \*\*\*\*\*/  
class Cliente \< ActiveRecord::Base  
has\_many :ingresos, :as =\> :origen  
end

/\*\*\*\*\* ingreso.rb \*\*\*\*\*/  
class Ingreso \< ActiveRecord::Base  
belongs\_to :origen, :polymorphic =\> true  
end

/\*\*\*\*\* test\_ingresos\_controller.rb \*\*\*\*\*/  
test “should show ingreso” do  
get :show, { :id =\> ingresos(:primero).to\_param }, { :usuario\_id =\>  
usuarios(:fulanito).id }

```
assert_response :success

```

end

/\*\*\*\*\* views/ingresos/show.html.erb

**Origen** \<%=h @ingreso.origen\_type %\>: \<%= @ingreso.origen.nombre %\>

Any help will be appreciated. Thanks in advance.
