Created
December 14, 2009 16:34
-
-
Save tjstankus/256186 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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