Skip to content

Instantly share code, notes, and snippets.

@ches
Created December 5, 2011 21:57
Show Gist options
  • Save ches/1435574 to your computer and use it in GitHub Desktop.
Save ches/1435574 to your computer and use it in GitHub Desktop.
Dev Machinist fixtures
namespace :db do
namespace :fixtures do
desc 'Create some dummy development data from factories'
task :create => :environment do
unless Rails.env.development? || Rails.env.test?
puts "This task generates random data and is not intended for use in production."
exit 1
end
unless admin = User.first(:conditions => { :username => 'admin' })
puts 'Initial user account not found -- be sure to run `rake db:seed` or `db:setup`.'
exit 1
end
require File.expand_path('spec/support/blueprints', Rails.root)
7.times { Note.make!(:owner => admin) }
3.times { Note.make!(:public, :owner => admin) }
puts "Sample data created!"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment