diff --git a/app/views/glossary_terms/index.csv.ruby b/app/views/glossary_terms/index.csv.ruby new file mode 100644 index 0000000..9a28b58 --- /dev/null +++ b/app/views/glossary_terms/index.csv.ruby @@ -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 diff --git a/app/views/glossary_terms/index.html.erb b/app/views/glossary_terms/index.html.erb index 5d5a996..20056e3 100644 --- a/app/views/glossary_terms/index.html.erb +++ b/app/views/glossary_terms/index.html.erb @@ -23,4 +23,6 @@ <%= render 'index_terms', terms: @glossary_terms %> <% end %> - +<% other_formats_links do |f| %> + <%= f.link_to_with_query_parameters 'CSV' %> +<% end %>