How to create tab-delimited text files

Hello Friends
I want to generate tab-delimited text file of my every users
information in once.
i have a button called EXPORT on my page when i clicked on this button
than i want to generate tab-delimited text file for every users
information.
can anybody give any snippet of code or any idea for this

Thanks

I'm not sure why you'd want to provide this functionality but here's a
stab at it (I'm sure someone will come up with something more elegant)

File.open('file.txt', 'a+') { |f| User.find(:all).each { |u|
f.write("#{u.login}\t#{u.email}\n") } }

Djdon Djdon wrote:

Hello Friends
I want to generate tab-delimited text file of my every users
information in once.
i have a button called EXPORT on my page when i clicked on this button
than i want to generate tab-delimited text file for every users
information.
can anybody give any snippet of code or any idea for this

Install fastercsv gem. Then in your code:

require 'fastercsv'

FasterCSV.generate(:col_sep => "\t") {|csv| csv << [user_name, last_login, etc.]}