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?
You need to add some default value for nome:
FactoryGirl.define do
factory :grau do
nome 'lorem'
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With