I created a file 'csv_string' as follows
def export_raw
@device = Device.find_by_id( params[:id] )
@messages = @device.devmessages.all( :order => "id", :conditions =>
["packettime >= ? and packettime <= ?", params[:start_time],
params[:end_time]] )
csv_string = FasterCSV.generate do |csv|
csv << ["Packet", "Server Receive Time"]
@messages.each_with_index do |m,i|
x = m.created_at
csv << [m.message, x.strftime('%h %d, %G %r')]
end
end
send_file csv_string, :type => "application/csv", :x_sendfile=> true,
:filename => "rawdata.csv"
# send_data(csv_string,
# :type => 'text/csv; charset=utf-8; header=present',
#:filename => filename)
end
I am able to download the file using
"send_data csv_string, :type => "application/csv", :filename
=>"rawdata.csv"
But I am unable to download same file using
"send_file csv_string, :type => "application/csv", :x_sendfile=> true,
:filename => "rawdata.csv"
It gives the error saying that string contains null byte.
Can anyone please help me in resolving this issue?
Thank you
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.