Attribute Ordering not working

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",
:eek: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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top