ezuk
ezuk

Reputation: 3196

Rails rake db:seed and FactoryGirl not getting along

Trying to use FactoryGirl to seed my development db with some data. Following this tutorial so my seeds.rb file looks like this:

require 'factory_girl'
Dir[Rails.root.join("spec/factories/*.rb")].each {|f| require f}

100.times do
  FactoryGirl.create :idea
end

When running rake db:seed it complains:

rake aborted!
Factory already registered: idea

Why is it a bad thing that the factory is registered? I'm trying to use it, not register it (whatever that means...). Any idea what I'm doing wrong?

Upvotes: 0

Views: 785

Answers (1)

Veraticus
Veraticus

Reputation: 16074

Most likely your factories are already being loaded. Try removing the line that does each of the requires and see if that corrects the issue.

Upvotes: 2

Related Questions