Rails App. I have a Project and a Task Model. Tasks have a column project_id to set the project they belong to, and several completeness columns to indicate completeness of the task over the time (so I have a column 'completeness_at_3hours', 'completeness_at_6hours' etc), to indicate from 1 to 5 the level of completeness of the task.
I now need to graph, with google charts the completeness over the time of the tasks that belong to a project.
In my Projects controller I have
@tasks = Tasks.where("project_id = ?", params[:id])
So, now that I have the tasks of the selected project, in @tasks, how would I include the data in the google chart script?
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Time', '<%= @task.name %>', '????????'],
['<%= @task.created_at %>', <%= @task.zerohours %>, '?????????'],
['<%= @task.created_at + 3.hours %>', <%= @task.threehours %>, '????????'],
['<%= @task.created_at + 6.hours %>', <%= @task.sixhours %>, '????????'],
['<%= @task.created_at + 9.hours %>', <%= @task.ninehours %>, '????????'],
['<%= @task.created_at + 12.hours %>', <%= @task.twelvehours %>, '????????']
]);
this works for only one task (the one that has just been created), but how do I pass to the script all the data contained in @tasks?
I mean, to retrieve the data in a simple table I would use:
<% @tasks.each do |task| %>
<%= @task.threehours %>
<%= @task.sixhours %>
<%= @task.ninehours %>
<%= @task.twelvehours %>
<% end %>
But how do I do the same thing but inside the google chart script?
Thanks a lot!!