【问题标题】:Using ChartKickjs with Sinatra and HAML将 ChartKickjs 与 Sinatra 和 HAML 一起使用
【发布时间】: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'}

【问题讨论】:

标签: ruby-on-rails ruby sinatra haml chartkick


【解决方案1】:

根据 haml 文档:

%barchart[@estimates]

将尝试创建一个<barchart> html 标记并使用@estimates 设置其id 和类。

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

我认为你想要实现的是:

= bar_chart @estimates

【讨论】:

    猜你喜欢
    • 2013-02-19
    • 1970-01-01
    • 1970-01-01
    • 2013-09-26
    • 1970-01-01
    • 1970-01-01
    • 2015-04-14
    • 2013-03-13
    • 1970-01-01
    相关资源
    最近更新 更多