Advertisement
Guest User

Untitled

a guest
Feb 26th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.22 KB | None | 0 0
  1. require 'csv'
  2.  
  3. file = "#{Rails.root}/public/data.csv"
  4.  
  5. schools = School.where(state_code: 'CO').order('name ASC')
  6.  
  7. CSV.open( file, 'w' ) do |writer|
  8. schools.each do |s|
  9. writer << [s.name, s.zipcode, s.id]
  10. end
  11. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement