Redmine JSON.parse 导致内部错误
Redmine JSON.parse leads to Internal error
我创建了一个创建附加页面的 redmine 插件。在页面模板中,我只想将 JSON 转换为数组并打印出来。
我的代码如下所示:
<% require 'json' %>
<% jsonArray = [{"content":"1D","createdTime":"09-06-2011 00:59"},{"content":"2D","createdtime":"09-06-2011 08:00"}] %>
<% objArray = JSON.parse(jsonArray) %>
<%= objArray.html_safe %>
但是当我开始使用 JSON.parse
redmine 时,就会出现如下错误:
Internal error
An error occurred on the page you were trying to access.
If you continue to experience problems please contact your Redmine administrator for assistance.
If you are the Redmine administrator, check your log files for details about the error.
Back
我安装了 ruby 'json' gem.
希望有人能帮助我,在此先感谢!
jsonArray
不是JSON数组,而是普通的Ruby数组。要从中生成 JSON,您需要使用 #to_json
方法。我不确定生成 JSON 并在之后立即解析它有什么意义。
调试 Redmine 的 "Internal error" 消息的一种方法是 监控它的日志。
如果您 运行 在 Linux 上使用它,最好的方法是
tail -f log/production.log
of 如果你在开发模式下 运行ning Redmine,它将是:
tail -f log/production.log
此外,要获得更好的错误,而不仅仅是 "something went wrong",您可以添加 rubygems,例如更好的错误 gem 来自
https://github.com/BetterErrors/better_errors
要添加它,只需打开您的 Gemfile
并粘贴:
group :development do
gem "better_errors"
gem "binding_of_caller"
end
然后 运行 再 bundle install
。
(请记住,它是在 "development" 组下添加的,所以你的 redmine 必须是 运行 开发模式。
我创建了一个创建附加页面的 redmine 插件。在页面模板中,我只想将 JSON 转换为数组并打印出来。
我的代码如下所示:
<% require 'json' %>
<% jsonArray = [{"content":"1D","createdTime":"09-06-2011 00:59"},{"content":"2D","createdtime":"09-06-2011 08:00"}] %>
<% objArray = JSON.parse(jsonArray) %>
<%= objArray.html_safe %>
但是当我开始使用 JSON.parse
redmine 时,就会出现如下错误:
Internal error An error occurred on the page you were trying to access. If you continue to experience problems please contact your Redmine administrator for assistance.
If you are the Redmine administrator, check your log files for details about the error.
Back
我安装了 ruby 'json' gem.
希望有人能帮助我,在此先感谢!
jsonArray
不是JSON数组,而是普通的Ruby数组。要从中生成 JSON,您需要使用 #to_json
方法。我不确定生成 JSON 并在之后立即解析它有什么意义。
调试 Redmine 的 "Internal error" 消息的一种方法是 监控它的日志。
如果您 运行 在 Linux 上使用它,最好的方法是
tail -f log/production.log
of 如果你在开发模式下 运行ning Redmine,它将是:
tail -f log/production.log
此外,要获得更好的错误,而不仅仅是 "something went wrong",您可以添加 rubygems,例如更好的错误 gem 来自 https://github.com/BetterErrors/better_errors
要添加它,只需打开您的 Gemfile
并粘贴:
group :development do
gem "better_errors"
gem "binding_of_caller"
end
然后 运行 再 bundle install
。
(请记住,它是在 "development" 组下添加的,所以你的 redmine 必须是 运行 开发模式。