From fd3fa195731ccabd75297d7a4b7a1cb9837f574b Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Fri, 16 Nov 2012 01:53:17 +0800 Subject: [PATCH] add fake data, execute by rake db:seed --- db/seeds.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/db/seeds.rb b/db/seeds.rb index 664d8c74..2561572c 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,3 +5,23 @@ # # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) # Mayor.create(:name => 'Daley', :city => cities.first) +require 'factory_girl' + +FactoryGirl.define do + factory :paper_record, class: "WritingJournal" do |f| + f.sequence(:paper_title_translations) {|n|{zh_tw: "tw_test #{n}", en: "en_test #{n}" }} + f.sequence(:journal_title_translations) {|n| {zh_tw: "tw_test #{n}", en: "en_test #{n}"}} + f.sequence(:keywords) {|n| "keywords #{n}"} + f.sequence(:abstract) {|n| "abstract #{n}"} + f.sequence(:isbn) {|n| "0714312#{n}#{n}#{n}"} + f.sequence(:year) {|n| "201#{n}"} + f.create_user_id BSON::ObjectId('4f45f3b9e9d02c5db9000067') #user_id, this is Chris' account + f.update_user_id BSON::ObjectId('4f45f3b9e9d02c5db9000067') #user_id, this is Chris' account + end +end + + +#product 50 records +50.times.each do + FactoryGirl.create(:paper_record) +end