seeds.rb revision 7e3ffdd270e31d82db163acaf6d0849cb7dda0e8
# 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).
#
# Create Admin User
:admin => true,
:password => 'foobar'
# Create Team
team = Team.create! \
:name => 'Lorem Ipsum',
:admin_user => user
# Create some other users
user = User.create! \
:email => "#{name}@example.com",
:password => 'foobar'
# add two users to the first team
team.users << user if i < 2
end
Dir["#{Rails.root}/db/seeds/*.xml"].each do |file|
basename = File.basename(file)
o = Ontology.new \
uri: "file://seeds/#{basename}",
name: basename.split(".")[0].capitalize,
description: Faker::Lorem.paragraph
o.import_from_xml File.open(file)
end
# Create 5 ontologies
5.times do |n|
o = Ontology.new \
uri: "schema://host/ontology/#{n}",
name: Faker::Lorem.words(2+rand(4)).join(" "),
description: Faker::Lorem.paragraph
o.import_from_xml File.open('test/fixtures/ontologies/valid.xml')
end