Problems with testing, foxy fixtures and polymorphism

Hi,

I’m using Rails version 2.3.2 but it seems that my fixtures are wrong
and when testing a relation among two models does not appear. I have no
problems executing the application, only with tests.

These are my fixtures:

/***** ingresos.yml *****/
primero:
origen: jack (Cliente)
tipo: Banco
fecha: 2009-06-05
cantidad: 10

/***** clientes.yml *****/
jack:
nombre: Jack Sephard

The error (The error ocurred while evaluating nil.nombre) is in this
line:

/***** show.html.erb *****/
<%=h @ingreso.origen_type %>: <%= @ingreso.origen.nombre %>

The models are these:

/***** ingreso.rb *****/
class Ingreso < ActiveRecord::Base
belongs_to :origen, :polymorphic => true

/***** cliente.rb *****/
class Cliente < ActiveRecord::Base
has_many :ingresos, :as => :origen
/**********************/

Any idea will be appreciated. Thanks in advance.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs