【发布时间】:2014-07-06 16:11:09
【问题描述】:
我正在尝试在我的Sinatra 应用程序中使用ChartKick。尝试创建条形图等控件时,出现错误提示
{:cash=>82, :securities=>58}:Hash 文件的未定义方法“id”: buffer.rb 位置:parse_object_ref 行:323
有解决这个问题的建议吗?
app.rb
...
@estimates = {:cash => cash_estimate, :securities=> sec_estimate}
haml :results
...
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'}
【问题讨论】:
-
另外,您可以省略标签上的
=和双引号。无论如何都会对变量进行插值。 haml.info/docs/yardoc/file.REFERENCE.html#ruby_interpolation_ -
@mus 感谢您的建议。我对 ruby 比较陌生,所以总是希望让我的代码看起来更像 ruby
标签: ruby-on-rails ruby sinatra haml chartkick