<%= co_author.co_author %> |
<%= co_author.email %> |
- <%= co_author.type%> |
+ <%= @co_author_relations.find(co_author.co_author_relations_id).relation \
+ unless co_author.co_author_relations_id.nil?%> |
<%= link_to 'Edit', edit_desktop_co_author_path(co_author), :class => "bt-edit" %> |
<%= link_to 'Destroy', desktop_co_author_path(co_author), method: :delete, confirm: 'Are you sure?', :class=>"bt-delete" %> |
diff --git a/db/seeds.rb b/db/seeds.rb
index 00825e32..9c90554c 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -2,8 +2,9 @@ require 'factory_girl'
require 'faker'
require 'json'
-WritingJournal.destroy_all
CoAuthor.destroy_all
+CoAuthorRelation.destroy_all
+WritingJournal.destroy_all
data = File.read("db/data")
data_json = JSON.parse(data)
@@ -16,13 +17,21 @@ name_en = name_en.map do |p| Faker::Name::name end
email = Array.new 51,""
email= email.map do |p| Faker::Internet.email end
-type = ["friend", "teacher", "student", "mate", "relation"]
+type = ["friend0", "teacher0", "student0", "mate0", "relation0", "friend1", "teacher1", "student1", "mate1", "relation1"]
+
FactoryGirl.define do
+ factory(:type, class: "CoAuthorRelation") do |f|
+ f.sequence(:relation_translations) do |n|
+ { zh_tw: "#{type[n%type.size]}",
+ en: "#{type[n%type.size]}" }
+ end
+ end
+
factory(:co_author_candidate, class: "CoAuthor") do |f|
f.sequence(:co_author_translations) do |n|
{ zh_tw: "#{name_tw[n]}",
- en: "#{name_en[n]}" }
+ en: "#{name_en[n]}" }
end
f.sequence(:type) do |n| "#{type[n%5]}" end
f.sequence(:email) do |n| "#{email[n]}" end
@@ -81,6 +90,9 @@ FactoryGirl.define do
end
end
+10.times.each do
+ FactoryGirl.create(:type)
+end
50.times.each do
FactoryGirl.create(:paper_record)
@@ -89,3 +101,4 @@ end
50.times.each do
FactoryGirl.create(:co_author_candidate)
end
+