From 1b4c76a4726c9ee5e0637d1955ad2d3c1c3a29f5 Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Thu, 6 Dec 2012 09:49:15 +0800 Subject: [PATCH] current version --- db/seeds.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 0cebb66c..e73cd4ca 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -28,6 +28,8 @@ file = ["1.png", "5.pdf", "2.png", "6.pdf", "3.png", "7.pdf", "4.png"] level = ["SCI", "SCIE", "SSCI", "AH & HCI", "EI", "CSCI", "CSSCI", "TSCI", "TSSCI", "THCI"] +rand = Random.new + FactoryGirl.define do factory(:journal_level, class: "JournalLevelType") do |f| f.sequence(:title_translations) do |n| @@ -38,10 +40,10 @@ FactoryGirl.define do factory(:upload_file, class: "WritingJournalFile") do |f| f.sequence(:file) do |n| - File.new(File.join(Rails.root, "db" ,"files", file[Random.rand(0..6)])) + File.new(File.join(Rails.root, "db" ,"files", file[rand.rand(0..6)])) end f.sequence(:title) do |n| - "#{file_desc[Random.rand(0..6)]}" + "#{file_desc[rand.rand(0..6)]}" end end @@ -112,16 +114,16 @@ FactoryGirl.define do f.sequence(:journal_level_types) do |n| level = [] - total_levels = Random.rand(1..JournalLevelType.count) + total_levels = rand.rand(1..JournalLevelType.count) total_levels.times do - level << JournalLevelType.all[Random.rand(0..JournalLevelType.count-1)] + level << JournalLevelType.all[rand.rand(0..JournalLevelType.count-1)] end level.uniq end f.sequence(:writing_journal_files) do |n| files = [] - total_files = Random.rand(1..7) + total_files = rand.rand(1..7) total_files.times do files << FactoryGirl.create(:upload_file) end files end