views:

67

answers:

1

Hi,

I have a model called TipoContato (table tipos_contato), if I pluralize this it will become tipo_contatos, so I added this to inflections:

inflect.irregular 'tipo_contato', 'tipos_contato'

OK, testing it in console it is perfect:

>> TipoContato
=> TipoContato(id: integer, descricao: string, created_at: datetime, updated_at: datetime)

But, when running test cases I get this error:

ActiveRecord::StatementInvalid: Mysql::Error: Table 'contacts_test.tipo_contatos' doesn't exist: DELETE FROM `tipo_contatos`

Trying to force rails to recognize my table I tried:

set_table_name 'tipos_contato'

And I got the very same error.

Rails 2.3.2

+2  A: 

Not sure if it's a bug, but there is a workaround. Change the name of the fixtures file to tipos_contato.yml. Next, wire this up in the unit test like so:

class TipoContatoTest < ActiveSupport::TestCase
  set_fixture_class :tipos_contato => TipoContato
  ...
end

Here's a post that describes this in a bit more detail.

dbarker