你好我一直在閱讀有關如何使用,使圖表谷歌,圖表上護欄,我已經安裝了插件,但我不`噸知道爲什麼我顯示了這個錯誤:谷歌-圖表上護欄
NameError in TankingLogsController#index
uninitialized constant TankingLogsController::GoogleChart
這是我indes.html.erb
<div class="container">
<%= image_tag @bar %>
<h1>Listing Tankings</h1>
<% if @tankinglog.count<1 %>
<p>
There are no tankings for this car. Do you want to <%= link_to 'create a new tanking', new_user_car_tanking_log_path(@user, @car)%>
</p>
<% else %>
<table class="table table-condensed">
<tr>
<th>Cost</th>
<th>Gallon</th>
<th>Km</th>
<th>Date</th>
<th>Gas Station's id</th>
<th></th>
</tr>
<% @tankinglog.each do |tankinglog| %>
<tr>
<td><%= tankinglog.cost %></td>
<td><%= tankinglog.gallon %></td>
<td><%= tankinglog.km %></td>
<td><%= tankinglog.date %></td>
<td><%= tankinglog.gas_station_id %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New tanking', new_user_car_tanking_log_path(@user, @car), :class => "btn btn-primary" %>
<% end %>
<br />
<br />
<%= link_to 'back', user_cars_path(current_user), :class => "btn btn-primary" %>
</div>
這裏是我的控制器
class TankingLogsController < ApplicationController
....
def index
@user = User.find(params[:user_id])
@car = @user.cars.find(params[:car_id])
@tankinglog = @car.tanking_logs.all
@bar = GoogleChart.pie(['1997',10],['1998',20],['1999',40],['2000',30]).to_url
end
end
我的Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.6'
gem 'pg', '0.13.2'
gem 'devise', '2.0.4'
gem 'haml-rails'
gem 'twitter-bootstrap-rails', '2.0.6'
gem 'sass-rails', '~> 3.2.3'
gem "rspec", "~> 2.10.0"
gem 'simplecov', :require => false, :group => :test
gem 'gchart'
我把那行放在我的Gemfile中,我得到這個錯誤:在這臺機器上可用的gem上找不到gem'google-charts-on-rails(> = 0)ruby'。 – Asantoya17 2012-08-01 21:29:45
我的壞 - 我認爲這是你正在使用的寶石 - 這是行不通的...在這種情況下,我建議使用一個寶石,無論如何,給你類似的功能 - 也許googlecharts:[http:// googlecharts.rubyforge.org/] – 2012-08-01 21:32:16
我遵循[http://googlecharts.rubyforge.org/]的步驟,但沒有更改,除了錯誤:ActionView :: CompiledTemplates :: Gchart – Asantoya17 2012-08-01 21:41:03