Skip to content

Instantly share code, notes, and snippets.

@tjstankus
Created December 14, 2009 16:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjstankus/256186 to your computer and use it in GitHub Desktop.
Save tjstankus/256186 to your computer and use it in GitHub Desktop.
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Major.create(:name => 'Daley', :city => cities.first)
require 'faker'
def random_persons
[].tap do |a|
3.times { a << Faker::Name.name }
end.split(', ')
end
def random_tags
[].tap do |a|
3.times { a << Faker::Internet.domain_word }
end.split(', ')
end
user = User.create(:email => 'user@example.com', :password => 'secret', :password_confirmation => 'secret', :email_confirmed => true)
group = Group.create(:name => 'Ducks Soccer', :user => user)
# Group acts_as_tagger
# Thing acts_as_taggable_on :tags, :persons
10.times do |i|
thing = Thing.create(:name => "Thing #{i+1}", :user => user, :group => group)
group.tag(thing, :with => random_tags, :on => :tags)
group.tag(thing, :with => random_persons, :on => :persons)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment