Skip to content

Commit

Permalink
Fix export csv error when there are no stories in the projects (#515)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmatiello authored and talyssonoc committed Feb 20, 2019
1 parent 612d59d commit a324d80
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions config/initializers/csv_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# assumption that that is what we get passed.
ActionController::Renderers.add :csv do |stories, options|
number_of_extra_columns = {}
number_of_extra_columns[:notes] = stories.map{ |story| story.notes.length }.max
number_of_extra_columns[:documents] = stories.map{ |story| story.documents.length }.max
number_of_extra_columns[:tasks] = stories.map{ |story| story.tasks.length }.max
number_of_extra_columns[:notes] = stories.map{ |story| story.notes.length }.max || 0
number_of_extra_columns[:documents] = stories.map{ |story| story.documents.length }.max || 0
number_of_extra_columns[:tasks] = stories.map{ |story| story.tasks.length }.max || 0

filename = options[:filename] || 'export.csv'
headers = Story.csv_headers.dup
headers.concat(extra_headers(number_of_extra_columns))
Expand Down

0 comments on commit a324d80

Please sign in to comment.