加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – needle / definition-context.rb:36:警告:

发布时间:2020-12-17 01:27:00 所属栏目:百科 来源:网络整理
导读:我在导轨3.1中安装了一个新的宝石针. 它正确安装,但是当我使用命令rails server –debugger启动我的rails时 我收到以下警告: .rvm/gems/ruby-1.9.2-p290/gems/needle-1.3.0/lib/needle/definition-context.rb:36: warning: undefining `initialize' may cau
我在导轨3.1中安装了一个新的宝石针.

它正确安装,但是当我使用命令rails server –debugger启动我的rails时

我收到以下警告:

.rvm/gems/ruby-1.9.2-p290/gems/needle-1.3.0/lib/needle/definition-context.rb:36: warning: undefining `initialize' may cause serious problems
.rvm/gems/ruby-1.9.2-p290/gems/needle-1.3.0/lib/needle/definition-context.rb:36: warning: undefining 'object_id' may cause serious problems
.rvm/gems/ruby-1.9.2-p290/gems/needle-1.3.0/lib/needle/definition-context.rb:36: warning: undefining '__send__' may cause serious problems

我怎么能摆脱它?

解决方法

问题在于针宝石本身.它这样做:

public_instance_methods -
[ "instance_eval","object_id","__id__","__send__","initialize","remove_const","method_missing","method","class","inspect","to_s","instance_variables","block_given?" ]

但是在Ruby 1.9中,public_instance_methods方法返回Symbol变体的对象,而不是String.那么有效的是:

[:__send__,<and other methods>] - ["__send__",<and other methods>]
=> [:__send__,<and other methods>]

什么时候不应该删除提供的数组中的那些方法.

这向我表明该库尚未针对Ruby 1.9进行更新(或至少已经过测试).我建议找到这个库的代码,分叉它然后应用一个补丁,使用map(&:to_sym)之类的东西将数组转换为符号来解决这个问题.

但请注意:可能存在其他情况,即1.8和1.9之间存在这些差异.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读