Created
April 23, 2015 08:53
-
-
Save Xiangshen-Meng/9b06f5356617757e0862 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' }]) | |
# Mayor.create(name: 'Emanuel', city: cities.first) | |
users = [ | |
{ | |
email: "test1@boxil.jp", | |
password: "testtest", | |
profile: { first_name: "沢田", last_name: "俊介", gender: "male", age: 32, company: "Canpath", phone: "08070099448" } | |
}, | |
{ | |
email: "test2@boxil.jp", | |
password: "testtest", | |
profile: { first_name: "高橋", last_name: "大輔", gender: "male", age: 22, company: "株式会社アイススケート", phone: "08070099448" } | |
}, | |
{ | |
email: "test3@boxil.jp", | |
password: "testtest", | |
profile: { first_name: "鈴木", last_name: "さとこ", gender: "female", age: 42, company: "エクルート", phone: "08070099448" } | |
} | |
] | |
users.each do |u| | |
user = User.create(email: u[:email], password: u[:password]) | |
user.build_profile(u[:profile]) | |
user.save | |
puts "User : #{user.full_name} is created." | |
end | |
1.upto(35) do |i| | |
Document.create( | |
user_id: 1, | |
title: "テスト資料#{i}", | |
description: "これはメッセージング機能開発のためのテスト資料です", | |
category_id: rand(1..10), | |
tag_list: ["売上を上げる", "コスト削減", "営業ノウハウ", "マーケティングのヒント", "ビックデータ活用"][rand(0..4)] | |
) | |
end | |
1.upto(5) do |i| | |
Document.create( | |
user_id: 1, | |
title: "テスト資料#{i}-recommended", | |
description: "これはメッセージング機能開発のためのテスト資料です", | |
category_id: rand(1..10), | |
recommended: true, | |
tag_list: ["売上を上げる", "コスト削減", "営業ノウハウ", "マーケティングのヒント", "ビックデータ活用"][rand(0..4)] | |
) | |
end | |
categories = [ | |
{ name: "ITサービス", slug: "it-service" }, | |
{ name: "システム開発", slug: "development" }, | |
{ name: "情報システム", slug: "info-service" }, | |
{ name: "ネットマーケティング", slug: "web-marketing" }, | |
{ name: "マーケティング", slug: "marketing" }, | |
{ name: "営業", slug: "sales" }, | |
{ name: "人事", slug: "recruit" }, | |
{ name: "経理・財務", slug: "finance" }, | |
{ name: "総務・企画", slug: "planning" }, | |
{ name: "メディア", slug: "media" }, | |
] | |
categories.each do |cat| | |
category = Category.create(name: cat[:name], slug: cat[:slug]) | |
puts "Category : #{category.name} is created." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment