gpt4 book ai didi

ruby-on-rails-3 - Googlecharts gem - 我把需求 'gchart' 放在哪里

转载 作者:行者123 更新时间:2023-12-03 13:37:21 24 4
gpt4 key购买 nike

在下一页上,它说明了如何使用 googlecharts gem

http://googlecharts.rubyforge.org/

它有一行说

require 'gchart'

我把这个放在哪里?在 gemfile 或 Controller 中?

编辑:
在我的 View 文件中,我有:
<%
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])%>"/>

最佳答案

您可以在 Gemfile 中指定一个 require 语句。 .见 Bundler documentation .

gem "googlecharts", :require => "gchart"

关于ruby-on-rails-3 - Googlecharts gem - 我把需求 'gchart' 放在哪里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7703079/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com