Guest User

Untitled

a guest
Jan 21st, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.21 KB | None | 0 0
  1. def generate_csv(column_names, records)
  2. CSV.generate do |csv|
  3. csv << column_names # add headers to the CSV
  4.  
  5. records.each do |record|
  6. csv << record.attributes.values_at(*column_names)
  7. end
  8. end
  9. end
Add Comment
Please, Sign In to add comment