[Phase-24]Add csv export
This commit is contained in:
parent
fd7c3c3deb
commit
3049324dd8
19
app/views/glossary_terms/index.csv.ruby
Normal file
19
app/views/glossary_terms/index.csv.ruby
Normal 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
|
@ -23,4 +23,6 @@
|
||||
<%= render 'index_terms', terms: @glossary_terms %>
|
||||
<% end %>
|
||||
|
||||
|
||||
<% other_formats_links do |f| %>
|
||||
<%= f.link_to_with_query_parameters 'CSV' %>
|
||||
<% end %>
|
||||
|
Loading…
Reference in New Issue
Block a user