Rails中2數據在一列中,而不是排明智的CSV寫的Rails
開發應用,我從數據庫值generating CSV
文件。獲取emails of users
並生成CSV,但寫入emails in one column instead of Row.
我試了很多,但沒有找到任何解決方案。
下面寫CSV的代碼controller file
@users = User.all
tempArr = []
@users.each do |u|
tempArr << u.email
end
respond_to do |format|
format.csv {
send_data tempArr.to_csv, :type => "text/csv", :filename => "usercsv.csv"
}
end
像
[email protected] [email protected] [email protected]
數據顯示想要顯示
[email protected]
[email protected]
[email protected]
任何人都有一個想法或誘騙到sortout。
在此先感謝
你需要數據的行或列,尚不清楚我? –
重複:http://stackoverflow.com/questions/13065130/rails-write-a-csv-file-column-wise –
@OlegSobchuk更新的問題,請檢查它。下面顯示我要如何顯示。 – user1780370