Commit cc9c6081 by Rocky Duan

update seed generator to generate tags

parent 6454dcb3
...@@ -107,6 +107,15 @@ namespace :db do ...@@ -107,6 +107,15 @@ namespace :db do
"lol", "lol",
] ]
tag_seeds = [
"artificial-intelligence",
"random rant",
"c++",
"c#",
"java-sucks",
"2012",
]
users = User.all.to_a users = User.all.to_a
puts "Generating threads and comments for #{commentable_id}..." puts "Generating threads and comments for #{commentable_id}..."
...@@ -117,6 +126,7 @@ namespace :db do ...@@ -117,6 +126,7 @@ namespace :db do
thread_seeds.each do |thread_seed| thread_seeds.each do |thread_seed|
comment_thread = CommentThread.new(commentable_id: commentable_id, body: thread_seed[:body], title: thread_seed[:title], course_id: "1") comment_thread = CommentThread.new(commentable_id: commentable_id, body: thread_seed[:body], title: thread_seed[:title], course_id: "1")
comment_thread.author = users.sample comment_thread.author = users.sample
comment_thread.tags = tag_seeds.sort_by{rand}[0..2].join(",")
comment_thread.save! comment_thread.save!
threads << comment_thread threads << comment_thread
3.times do 3.times do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment