Trait not registred: attribute name
Asked Answered
C

1

5

Having trouble getting this done. I am using seed.rb + factory_girl to populate database with rake db:seed.

(I know that fixtures exists, but I want to get this done this way, this is just an example, the DB will be populated with complex association objects.)

My seed.rb:

require 'factory_girl_rails'
["QM","CDC","SI","QS"].each do |n|
  FactoryGirl.create(:grau, nome: n)
end

and my /factories/graus.rb

FactoryGirl.define do
  factory :grau do
    nome
  end
end

but when I run:

rake db:seed

I get:

rake aborted!
Trait not registered: nome

Tasks: TOP => db:seed

Any hints?

Calais answered 10/8, 2012 at 14:48 Comment(0)
T
16

You need to add some default value for nome:

FactoryGirl.define do
  factory :grau do
    nome 'lorem'
  end
end
Tannie answered 10/8, 2012 at 18:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.