F
Francisca Munhoz
Hi I'm learning Ruby, so I have a beginner question.
How Can I sort attributes values for similar order as my csv_header
array? Just consider that I already order my query but it did not work.
When I open my CSV file I can see the lastname under the address column.

@custom_csv = User.find
all,:select => "name, lastname, address",
rder => "name, lastname, address")
csv_header = [name,lastname,address]
csv_string = FasterCSV.generate do |csv|
csv << csv_header
@custom_csv.each do |v|
csv << v.attributes.values
end
end
send_data csv_string, :type => "text/plain",
:filename=>"custom_user_report.csv",
:disposition => 'attachment'
If someone could give a little help in here, that would be great!
Thanks in advance!
How Can I sort attributes values for similar order as my csv_header
array? Just consider that I already order my query but it did not work.
When I open my CSV file I can see the lastname under the address column.
@custom_csv = User.find
csv_header = [name,lastname,address]
csv_string = FasterCSV.generate do |csv|
csv << csv_header
@custom_csv.each do |v|
csv << v.attributes.values
end
end
send_data csv_string, :type => "text/plain",
:filename=>"custom_user_report.csv",
:disposition => 'attachment'
If someone could give a little help in here, that would be great!
Thanks in advance!