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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Apr 8, 3:35 pm, Everton Lucas <evtlu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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) >It looks like the autogenerated fixtures file contains data that is too long for some of your columns (I think rails just puts MyString in all string fields, but some of your columns only have length 2) Fred -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Yes I have the column estado with 2 characters. But if I define :estado => "RS" the error continues. On 8 abr, 13:18, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Apr 8, 3:35 pm, Everton Lucas <evtlu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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) > > It looks like the autogenerated fixtures file contains data that is > too long for some of your columns (I think rails just puts MyString in > all string fields, but some of your columns only have length 2) > > Fred-- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I''m using PostgreSQL to build the application. On 8 abr, 13:45, Everton Lucas <evtlu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yes I have the column estado with 2 characters. But if I > define :estado => "RS" the error continues. > > On 8 abr, 13:18, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Apr 8, 3:35 pm, Everton Lucas <evtlu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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) > > > It looks like the autogenerated fixtures file contains data that is > > too long for some of your columns (I think rails just puts MyString in > > all string fields, but some of your columns only have length 2) > > > Fred-- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 8 April 2010 17:45, Everton Lucas <evtlucas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yes I have the column estado with 2 characters. But if I > define :estado => "RS" the error continues. > > On 8 abr, 13:18, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> On Apr 8, 3:35 pm, Everton Lucas <evtlu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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) >> >> It looks like the autogenerated fixtures file contains data that is >> too long for some of your columns (I think rails just puts MyString in >> all string fields, but some of your columns only have length 2) >>I think Fred meant you to look in the fixtures file that rails may have autogenerated for you (test/fixtures/participantes.yml) and check the lengths of data there. Colin -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I wil see. Even I use the command rake test:units, will fixtures be loaded? On 8 abr, 16:39, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 8 April 2010 17:45, Everton Lucas <evtlu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Yes I have the column estado with 2 characters. But if I > > define :estado => "RS" the error continues. > > > On 8 abr, 13:18, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> On Apr 8, 3:35 pm, Everton Lucas <evtlu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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) > > >> It looks like the autogenerated fixtures file contains data that is > >> too long for some of your columns (I think rails just puts MyString in > >> all string fields, but some of your columns only have length 2) > > I think Fred meant you to look in the fixtures file that rails may > have autogenerated for you (test/fixtures/participantes.yml) and check > the lengths of data there. > > Colin-- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Apr 8, 9:22 pm, Everton Lucas <evtlu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I wil see. Even I use the command rake test:units, will fixtures be > loaded?Yup. Fixtures are loaded no matter how you run the tests. Fred> > On 8 abr, 16:39, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > > > On 8 April 2010 17:45, Everton Lucas <evtlu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Yes I have the column estado with 2 characters. But if I > > > define :estado => "RS" the error continues. > > > > On 8 abr, 13:18, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >> On Apr 8, 3:35 pm, Everton Lucas <evtlu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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) > > > >> It looks like the autogenerated fixtures file contains data that is > > >> too long for some of your columns (I think rails just puts MyString in > > >> all string fields, but some of your columns only have length 2) > > > I think Fred meant you to look in the fixtures file that rails may > > have autogenerated for you (test/fixtures/participantes.yml) and check > > the lengths of data there. > > > Colin > > -- > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
It works. I had fixtures automatically generated with ''MyString''. Thanks for all help. On 8 abr, 18:55, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Apr 8, 9:22 pm, Everton Lucas <evtlu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I wil see. Even I use the command rake test:units, will fixtures be > > loaded? > > Yup. Fixtures are loaded no matter how you run the tests. > > Fred > > > > > > > On 8 abr, 16:39, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > On 8 April 2010 17:45, Everton Lucas <evtlu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Yes I have the column estado with 2 characters. But if I > > > > define :estado => "RS" the error continues. > > > > > On 8 abr, 13:18, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > >> On Apr 8, 3:35 pm, Everton Lucas <evtlu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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) > > > > >> It looks like the autogenerated fixtures file contains data that is > > > >> too long for some of your columns (I think rails just puts MyString in > > > >> all string fields, but some of your columns only have length 2) > > > > I think Fred meant you to look in the fixtures file that rails may > > > have autogenerated for you (test/fixtures/participantes.yml) and check > > > the lengths of data there. > > > > Colin > > > -- > > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.