morris.js Rails Ruby 中的错误

morris.js error in Ruby on Rails

当我尝试在 Rails 项目的 Ruby 中使用 morris.js 时出现错误。

Uncaught TypeError: Cannot read property 'length' of undefined

这是我的文件

= content_tag :div, "", id: "weights_chart", data: {weights: @weights}
:javascript
   new Morris.Line({
       element: 'weights_chart',
       data: $('#weights_chart').data('weights'),
       xkey: 'created_at',
       ykey: ['data'],
       labels: ['Weight']
   });

ykey 应该是 ykeys 最有可能。