Hi Folks

I'm brand new in rails. I'm trying to build a little application, and
when I tried to run a unit test, I got an error. The error follows
below:

ActiveRecord::StatementInvalid: PGError: ERROR:  value too long for
type character varying(2)

The migration is:

class CreateParticipantes < ActiveRecord::Migration
  def self.up
    create_table :participantes do |t|
      t.string :cpf, :limit => 11
      t.string :nome, :limit => 100
      t.string :apelido, :limit => 50
      t.string :sexo, :limit => 1
      t.string :rg, :limit => 15
      t.string :emissor, :limit => 10
      t.date :datanascimento
      t.string :nomeresponsavel, :limit => 100
      t.string :rgresponsavel, :limit => 15
      t.string :parentesco, :limit => 50
      t.string :endereco, :limit => 100
      t.string :cidade, :limit => 100
      t.string :estado, :limit => 2
      t.string :cep, :limit => 8
      t.string :email, :limit => 255
      t.string :telefone, :limit => 10
      t.string :celular, :limit => 10
      t.boolean :possuiplanosaude
      t.string :planodesaude, :limit => 50
      t.string :clube, :limit => 50
      t.string :nomeemergencia, :limit => 100
      t.string :telefoneemergencia, :limit => 10
      t.text :doenca
      t.text :alergias
      t.boolean :usacelular
      t.boolean :eventoanterior
      t.string :senha, :limit => 50

      t.timestamps
    end

    add_index(:participantes, :cpf)
  end

  def self.down
    drop_table :participantes
  end
end

And the test class is:

require 'test_helper'

class ParticipanteTest < ActiveSupport::TestCase
  def test_insercao_correta
    participante = Participante.create(:cpf => "93468920059")
    assert(participante.valid?);
  end
end

I could run the code inside test_insercao_correta in a shell script
using the test database and the develop database.

When the result had shown in a shell, I saw the following query (I'm
calling query, but I don't know if it is really a query);
INSERT INTO "participantes" ("doenca", "celular", "updated_at",
"alergias", "planodesaude", "eventoanterior", "endereco",
"nomeemergencia", "possuiplanosaude", "cep", "datanascimento", "nome",
"cpf", "usacelular", "clube", "rgresponsavel", "id",
"nomeresponsavel", "cidade", "parentesco", "emissor", "apelido",
"sexo", "created_at", "senha", "telefoneemergencia", "telefone",
"email", "estado", "rg") VALUES (E'MyString', E'MyString',
E'2010-04-08 02:16:38', E'MyString', E'MyString', 'f', E'MyString',
E'MyString', 'f', E'MyString', '2010-03-17', E'MyString', E'MyString',
'f', E'MyString', E'MyString', 298486374, E'MyString', E'MyString',
E'MyString', E'MyString', E'MyString', NULL, E'2010-04-08 02:16:38',
E'MyString', E'MyString', E'MyString', E'MyString', E'MyString',
E'MyString')

Is there someone could help me?

Thanks in advance

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to