Я пытаюсь реализовать ленивые высокие графики, используя следующий сайт github GitHub Я сделал следующие шаги
Установка плагина rails git: //github.com/michelson/lazy_high_charts.git
@ h = LazyHighCharts :: HighChart.new ('graph') do | f |
f.series (: name => 'John',: data => [3, 20, 3, 5, 4, 10, 12, 3, 5,6,7,7,80,9,9])
f.series (: name => 'Jane',: data => [1, 3, 4, 3, 3, 5, 4, -46,7,8,8,9,9,0,0,9] )
конец
- <% = javascript_include_tag 'highcharts'%>
- <% = high_chart ("my_id", @h)%>
Что сбивает с толку, так это то, что я дошел до того, что он говорит вам поместить код в контроллер, но не говорит вам, где именно. Поэтому я попытался выполнить некоторые из следующих действий, и это были результаты
1)
class DashboardController < ApplicationController
access_control do
actions :index do
allow :Admin
end
end
def index
@title = "Welcome to Dashboard"
before_filter :authenticate, :only => [:index]
@h = LazyHighCharts::HighChart.new('graph') do |f|
f.series(:name=>'John', :data=>[3, 20, 3, 5, 4, 10, 12 ,3, 5,6,7,7,80,9,9])
f.series(:name=>'Jane', :data=> [1, 3, 4, 3, 3, 5, 4,-46,7,8,8,9,9,0,0,9] )
end
end
end
Результат =
Routing Error
uninitialized constant DashboardController::LazyHighCharts
2)
class DashboardController::LazyHighCharts < ApplicationController
before_filter :authenticate, :only => [:index]
@h = LazyHighCharts::HighChart.new('graph') do |f|
f.series(:name=>'John', :data=>[3, 20, 3, 5, 4, 10, 12 ,3, 5,6,7,7,80,9,9])
f.series(:name=>'Jane', :data=> [1, 3, 4, 3, 3, 5, 4,-46,7,8,8,9,9,0,0,9] )
end
access_control do
actions :index do
allow :Admin
end
end
def index
@title = "Welcome to Dashboard"
end
end
Просмотр
<%= javascript_include_tag 'jquery.dataTables.min', 'datatable', 'jquery.dataTables.columnFilter'%>
<%= stylesheet_link_tag 'demo_table', 'jquery-ui-1.8.4.custom' %>
<%= javascript_include_tag 'highcharts'
<div class="head">
<h1>Welcome to Dashboard</h1>
</div>
<div class="row">
<div class="um rollover" id="um"><a><center><%= link_to image_tag("User.png", :alt => "User Management", :height => "100"), usermanagement_path %></center><br /><center>User Management</center><br /></a></div>
<div class="pm rollover" id="pm"><a><center><%= link_to image_tag("Project.png", :alt => "Project Management", :height => "100"), projects_path %></center><br /><center>Project Management</center><br /></a></div>
<div class="ts rollover" id="ts"><a><center><%= link_to image_tag("Timesheet.png", :alt => "Timesheets", :height => "100"), timesheet_path %></center><br /><center>Timesheets</center><br /></a></div>
<div class="crm rollover" id="crm"><a><center><%= link_to image_tag("Customer.png", :alt => "Customer Relation Management", :height => "100"), crm_path %></center><br /><center>Customer Relation Management</center><br /></a></div>
</div>
<%= high_chart("my_id", @h) %>
Результат =
LoadError in DashboardController#index
Expected c:/Users/patterd/documenTS/PadOnRails/app/controllers/dashboard_controller.rb to define DashboardController
Я пробовал оба эти способа и получал разные ошибки. Я все еще новичок в ror и javascript, так что это может показаться вам довольно простым. Есть ли какие-либо предложения или советы, где я иду не так?