开发者

rails3+ruby1.9.2p0+ubuntu+CSV

I get the following error with CSV in (Rails3, ruby 1.9.2p0, ubuntu)

when i use CSV.generate { |csv| ... } i get the error

error in generate - worng number of arguements(0 for 1)

when i use CSV.generate({}) { |csv| ... } i get the error

TypeError cant conv开发者_如何学Goert hash into string

please, can you help me with the soluton for this.

code i used

csv_data = CSV.generate do |csv| csv << [ "S_No", "User ID", "Password" ]

@password_array.each do |password| csv << [ @user_name, @user_id, @password] end

end

thanks


The CSV.generate method expects a string as the first argument. It can be an empty string if you want, so try this:

csv_data = CSV.generate("") { |csv| ... }

For more information, read the documentation of the Ruby CSV class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜