[Phase-24]Add csv export

This commit is contained in:
TAKAHASHI,Toru committed 2020-01-02 19:39:21 +09:00
1 parent fd7c3c3deb
commit 3049324dd8
2 files changed
+22 -1

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
require 'csv'
CSV.generate(row_sep: "\r\n", encoding: "CP932") do |csv|
column_names = ["name", "name_en", "category", "datatype", "codename", "description", "rubi", "abbr_whole"]
csv << column_names
@glossary_terms.each do |term|
column_values = [
term.name,
term.name_en,
term.category&.name,
term.datatype,
term.codename,
term.description,
term.rubi,
term.abbr_whole
]
csv << column_values
end
end
+3 -1
View File
@@ -23,4 +23,6 @@
<%= render 'index_terms', terms: @glossary_terms %>
<% end %>
<% other_formats_links do |f| %>
<%= f.link_to_with_query_parameters 'CSV' %>
<% end %>