require 'csv' file = "my_file.csv" CSV.open( file, 'w' ) do |writer| @coun.each do |c| writer << [c.name, c.country_code, c.user_id, c.subscriber_id] end end