Errr... if you want the data sorted, you have to sort it - it's not going to magically be in the order you want! Throw an ORDER BY clause in your SQL.
Are you talking about the ordering of the rows or of the columns?
Fred
Attributes of an AR object don't have an order, so you need to specify it explicity when you call to_csv. As per the docs for to_csvm you can do this with the :order or :only options
Fred
sorry, i couldn't understand clearly, could you please can you explain little bit clear?
Read the docs for to_csv http://svn.integralserver.com/plugins/to_csv/README
Again… read the docs.
http://svn.integralserver.com/plugins/to_csv/README
:order - Array of columns in explicit order
so
@foo.to_csv(:order=>[:title:, :first_name, :middle_name, :last_name,:suffix, :company, :job_title, :business, :street])
To be successful with Rails, learn how to not only read but interpret the documentation. All of this code is open source so even if the docs aren’t clear, you should be able to open the source code and see what it’s doing.
A wise developer once said that you shouldn’t use any code unless you understand how it works.