Rails ActiveSupport::JSON 导致非法指令错误
我正在尝试将 Rails 项目中的某些内容编码为 JSON,但似乎对 Rails 中任何 JSON API 的任何调用都会导致 WEBrick 抛出 “非法指令”
错误。
我的代码是:
@nodes = Node.all
j = ActiveSupport::JSON
@json = j.encode(@nodes)
我不明白为什么会出现此错误。有人可以帮忙吗?
不确定这是否相关,但我也在使用 mysql2spatial 适配器,因为我的 Node 类包含一个类型为 GEOMETRY 的字段(mysql 空间扩展) )。
谢谢!
I'm trying to encode something in my rails project into JSON, but it seems like any call to any JSON API in Rails causes WEBrick to throw a "Illegal Instruction"
error.
My code was:
@nodes = Node.all
j = ActiveSupport::JSON
@json = j.encode(@nodes)
I don't understand why I get this error. Can someone please help?
Not sure if this is relevant, but I'm also using mysql2spatial
adapter because my Node
class contains a field with type GEOMETRY
(mysql spatial extensions).
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JSON gem 需要编译扩展,因此您的版本可能未针对您当前使用的体系结构或操作系统进行编译。您可能需要重新安装它,看看是否可以解决问题。
Ruby 本身很少抛出异常,但编译的扩展更频繁地抛出异常,尤其是针对不同的系统库集进行编译时。
The JSON gem requires compiled extensions, so it's possible that your version isn't compiled for the architecture or OS you're currently using. You may want to re-install it and see if that resolves the problem.
Ruby itself rarely throws exceptions, but compiled extensions do this much more frequently, especially if compiled against a different set of system libraries.