在rails undefined方法`to

编程入门 行业动态 更新时间:2024-10-24 11:22:49
在rails undefined方法`to_h'错误中从zurb foundation 5到6更新(Update from zurb foundation 5 to 6 in rails undefined method `to_h' error)

昨天我更新了我的rails-app的宝石。 现在,而不是基础5,我正在使用版本6

gem 'foundation-rails'

但是自从更新后我每次尝试加载页面时都会收到以下错误:

undefined method `to_h' for nil:NilClass

我将错误跟踪到Application.html.erb中的以下代码行

<%= javascript_include_tag "application", 'data-turbolinks-track' => true %>

如果我删除该行应用程序工作正常(但由于缺少javascript,一些样式等不起作用)。

我真的很无能为什么我得到这个错误,这里的搜索和谷歌也没有任何帮助。 我也试过了

rails g foundation:install

没有成功。 我在用

ruby 1.9.3p-194 Rails 4.1.4

由于我没有找到任何线索,如果基础6需要更新版本,我不确定错误是否必须对此做些什么。

每个提示都表示赞赏,谢谢! 斯文

Yesterday I updated the gems for my rails-app. Now instead of foundation 5 I'm using version 6 with the

gem 'foundation-rails'

But since the update I get the following error everytime I try to load a page:

undefined method `to_h' for nil:NilClass

I tracked the error to the following line of Code in my Application.html.erb

<%= javascript_include_tag "application", 'data-turbolinks-track' => true %>

If I erase that line the app works fine (yet some Styles, etc do not work due to the missing javascript).

I am actually clueless why I get this error and neither the search here nor google could be of any help. I also tried

rails g foundation:install

without sucess. I am using

ruby 1.9.3p-194 Rails 4.1.4

Since I didn't find any clue if foundation 6 needs a newer version I'm not sure whether the error has to do something with that or not.

Every hint is appreciated, Thanks! Sven

最满意答案

更新您的Ruby版本, to_h方法仅适用于Ruby 2.1或更高版本。

我假设在代码中的某处存在如下构造:

=> something_what_actually_can_be_nil.to_h

和期望的结果是空哈希(ruby 2.1):

=> nil.to_h #> {}

Update your Ruby version, the to_h method is only available in Ruby version 2.1 or higher.

I assume somewhere in the code exists the construction like:

=> something_what_actually_can_be_nil.to_h

and expected result is empty hash (ruby 2.1):

=> nil.to_h #> {}

更多推荐

本文发布于:2023-04-27 14:18:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1327149.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方法   rails   undefined

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!