Skip to content

Commit 0322e67

Browse files
authored
Merge pull request #109 from indentlabs/export-improvement
Treat deleted universe links as deleted in content exporting
2 parents b303197 + c87cc02 commit 0322e67

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

app/controllers/export_controller.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def to_csv ar_relation
5858
if value.is_a?(ActiveRecord::Associations::CollectionProxy)
5959
value = value.map(&:name).to_sentence
6060
elsif attr.end_with?('_id') && value.present?
61-
value = Universe.find(value.to_i).name
61+
universe = Universe.where(id: value.to_i).first
62+
value = universe.name if universe
6263
end
6364

6465
value
@@ -80,7 +81,8 @@ def to_json ar_relation
8081
if value.is_a?(ActiveRecord::Associations::CollectionProxy)
8182
value = value.map(&:name).to_sentence
8283
elsif attr.end_with?('_id') && value.present?
83-
value = Universe.find(value.to_i).name
84+
universe = Universe.where(id: value.to_i)
85+
value = universe.name if universe
8486
end
8587

8688
content_json[attr] = value
@@ -109,7 +111,8 @@ def content_to_outline
109111
if value.is_a?(ActiveRecord::Associations::CollectionProxy)
110112
value = value.map(&:name).to_sentence
111113
elsif attr.end_with?('_id') && value.present?
112-
value = Universe.find(value.to_i).name
114+
universe = Universe.where(id: value.to_i)
115+
value = universe.name if universe
113116
end
114117

115118
text << " #{attr}: #{value.split("\n").join("\n ")}\n"

0 commit comments

Comments
 (0)