在下面的页面中,它说明了如何使用googlecharts gem。
http://googlecharts.rubyforge.org/
上面有一行写着
require 'gchart'我该把这个放在哪里?在gemfile中还是在控制器中?
编辑:在我的视图文件中,我有:
<%
require 'gchart'
Gchart.line(:size => '200x300',
:title => "example title",
:bg => 'efefef',
:legend => ['first data set label', 'second data set label'],
:data => [10, 30, 120, 45, 72])
%>但上面没有显示图像
编辑2:图表现在可以工作了,下面是我使用的代码
<% require 'gchart' %>
<img src="<%=Gchart.line(:data => [0, 40, 10, 70, 20])%>"/>发布于 2011-10-10 03:31:44
可以在Gemfile中指定require语句。参见Bundler documentation。
gem "googlecharts", :require => "gchart"发布于 2012-09-12 00:31:19
您必须重新启动服务器
https://stackoverflow.com/questions/7703079
复制相似问题