0

我正在尝试在我的Sinatra应用程序中使用ChartKick 。尝试创建条形图等控件时,我收到一条错误消息

{:cash=>82, :securities=>58} 的未定义方法“id”:哈希文件:buffer.rb 位置:parse_object_ref 行:323

有关解决此问题的任何建议?

应用程序.rb

...
 @estimates = {:cash => cash_estimate, :securities=> sec_estimate}
haml :results
...

结果.haml

%label="By saving cash you will be able to retire at the age of  #{@estimates[:cash]}}."
%br
%label="Choosing to invest your savings in stock securities may allow you to retire at #{@estimates[:securities]}."

%barchart[@estimates]

%script{:type => 'text/javascript', :src => '//www.google.com/jsapi'}
%script{:type => 'text/javascript', :src => '/js/chartkick.js'}
4

1 回答 1

2

根据haml docs:

%barchart[@estimates]

将尝试创建一个<barchart>html 标签并使用@estimates它来设置它的 id 和 class。

http://haml.info/docs/yardoc/file.REFERENCE.html#object_reference_

我认为你想要实现的是:

= bar_chart @estimates
于 2014-07-06T16:39:05.517 回答