[Phase-24]Add csv export

This commit is contained in:
TAKAHASHI,Toru 2019-12-08 03:05:44 +09:00
parent fd7c3c3deb
commit 3049324dd8
2 changed files with 22 additions and 1 deletions

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

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 %>