ruby 1.9.2的fastcsv错误 [英] fastercsv error with ruby 1.9.2
问题描述
我有一个在 ruby 1.9.2 和 linux 上运行的现有 rails 应用程序,它的 rails 版本是
I have an existing rails application I'm running on ruby 1.9.2 and linux its rails version is
rails 2.3.8
它也有一个 GEMFILE,在它的 vendor/gems 目录中它有 'fastercsv-1.5.4' gem
并且在它的迁移中(在两次迁移中)它需要 gem 'fastercsv'
and it has a GEMFILE as well, in its vendor/gems directory it has 'fastercsv-1.5.4' gem
and in its migrations (in two migrations) it has required the gem 'fastercsv'
require 'fastercsv'
但是当我这样做时
rake db:migrate
迁移声明失败
请切换到 Ruby 1.9 的标准 CSV 库.它是 FasterCSV 加上对 Ruby 1.9 的 m17n 编码引擎的支持."
我发现消息来自 gems 'faster_csv.rb' 文件.因为它有条件检查 ruby 版本
and I have found out the message comes from gems 'faster_csv.rb' file. as it has a condition to check the ruby version
if RUBY_VERSION >= "1.9"
class FasterCSV
def self.const_missing(*_)
raise NotImplementedError, "Please switch to Ruby 1.9's standard CSV " +
"library. It's FasterCSV plus support for " +
"Ruby 1.9's m17n encoding engine."
end
def self.method_missing(*_)
const_missing
end
def method_missing(*_)
self.class.const_missing
end
end
-- and more code
谁能告诉我如何解决这个问题.请注意,fastercsv"尚未添加到 GEMFILE.
Can someone tell me how to fix this issue. Please note 'fastercsv' has not been added to the GEMFILE.
推荐答案
我找到了我的问题的答案
I found the answer to my question
基于这篇文章
作为解决方案,我不得不
and as the solution i had to
require 'csv'
而不是
require 'fastercsv'
并将 FasterCSV 更改为 CSV
and change the FasterCSV to CSV
这篇关于ruby 1.9.2的fastcsv错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!