使用ruby 1.9.2更快速地导致错误 [英] fastercsv error with ruby 1.9.2

查看:80
本文介绍了使用ruby 1.9.2更快速地导致错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的rails应用程序,我在ruby 1.9.2上运行,而linux的rails版本是

  rails 2.3 .8 

它也有一个GEMFILE,它的vendor / gems目录中有'fastercsv- 1.5.4'gem

并且在其迁移中(两次迁移),它需要gem'fastercsv'

  require'fastercsv'

但是当我做
$ b时$ b

  rake db:migrate 

请转换到Ruby 1.9的标准CSV库,它的速度更快,支持Ruby 1.9的m17n编码引擎。

我发现这条消息来自gems'faster_csv.rb'文件。因为它有条件检查ruby版本

 如果RUBY_VERSION> =1.9

class FasterCSV
def self.const_missing(* _)
raise NotImplementedError,请切换到Ruby 1.9的标准CSV+
库,它的速度更快,支持+
Ruby 1.9的m17n编码引擎。
end

def self.method_missing(* _)
const_missing
end

def method_missing(* _)
self .class.const_missing
结束
结束

- 更多代码

有人可以告诉我如何解决这个问题。请注意'fastercsv'没有被添加到GEMFILE中。

解决方案

我找到了我的问题的答案。 b
$ b

基于这篇文章

什么是Ruby 1.9标准的CSV库?



以及我不得不



  require'csv'

而非

 要求'fastercsv'

并将FasterCSV更改为CSV


I have an existing rails application I'm running on ruby 1.9.2 and linux its rails version is

rails 2.3.8

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'

But when I do

rake db:migrate 

it fails the migration claiming

"Please switch to Ruby 1.9's standard CSV library. It's FasterCSV plus support for Ruby 1.9's m17n encoding engine."

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

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

Its based on this post

What is Ruby 1.9 standard CSV library?

and as the solution i had to

require 'csv'

instead of

require 'fastercsv'

and change the FasterCSV to CSV

这篇关于使用ruby 1.9.2更快速地导致错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆