Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Rails 3.0.5 load test fixtures doesn't undestand has_many associations #879

Closed
lighthouse-import opened this Issue May 16, 2011 · 2 comments

Comments

Projects
None yet
1 participant

Imported from Lighthouse. Original ticket at: http://rails.lighthouseapp.com/projects/8994/tickets/6488
Created by Wylliam Miguita - 2011-03-01 15:14:05 UTC

After smelly fix of ticket #6479 (https://rails.lighthouseapp.com/projects/8994/tickets/6479-model-associations-are-trying-to-select-singular-table-names-after-305-upgrade) through inflections, the following error occurs while running tests:

ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'categoria' in 'field list': INSERT INTO `hierarquias` (`categoria`, `subcategoria`) VALUES ('jazz', 'big_bands')

where:

class Categoria << ActiveRecord::Base
  has_many :hierarquias
  has_many :subcategorias, :through => :hierarquias, :class_name => "Subcategoria", :foreign_key => :categoria_id
end

class Hierarquia << ActiveRecord::Base
  belongs_to :categoria
end

class Subcategoria < Categoria
  has_one :hierarquia
  has_one :categoria, :through => :hierarquia
end

Imported from Lighthouse.
Comment by Wylliam Miguita - 2011-02-28 19:32:03 UTC

forgot the fixtures:
categorias.yml

musica_brasileira:
    nome: música brasileira
    type: Categoria
jazz:
    nome: jazz
    type: Categoria
rock:
    nome: rock
    type: Categoria
choro:
    nome: choro
    type: Subcategoria
samba:
    nome: samba
    type: Subcategoria
big_bands:
    nome: big banda
    type: Subcategoria
jazz_classico:
    nome: jazz classico
    type: Subcategoria

hierarquias.yml

mb_choro:
    categoria: musica_brasileira
    subcategoria: choro
mb_samba:
    categoria: musica_brasileira
    subcategoria: samba
jazz_big:
    categoria: jazz
    subcategoria: big_bands
jazz_jazz_classico:
    categoria: jazz
    subcategoria: jazz_classico

Imported from Lighthouse.
Comment by Wylliam Miguita - 2011-04-07 16:04:16 UTC

You can call off this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment