Using factory_girl within a rake task - getting uninitialized constant
I'm guessing that Rails hasn't loaded your models at the point you are requiring the factories. Try this:
require 'factory_girl'
namespace :users do
desc "Create sample users for use in development"
task :create_sample_users => :environment do
require File.expand_path("spec/factories.rb")
Factory(:user, :email => "[email protected]")
Factory(:approved_user, :email => "[email protected]")
end
end