i am using ruby 1.9.2 and also use its csv library.I want to write in csv properly just
like this
name,country_code,destination,code Afghanistan,93,Bama
I think general CSV writer will be good enough for you:
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