I'm trying to make some charts on my app, and so I've started using http://www.jqplot.com/index.php
It uses arrays to input the data, so I'm trying to create some arrays of my data in ruby, that I can then print in the javascript.
i.e. @array_example = [1,2,3,4,5] wouldn't work when printed, but @array_example = "[1,2,3,4,5]" would work.
Anyway, The first my question would be, if I have:
<% @chart_posts = Post.where(:user_id => @profile.user.id) %>
Whats a good way to use this data to make an array (if I want the id of each post in the array, and a second array with the created_at)?
To be a little more clear, the final arrary needs to look like an array when printed.
i.e. it must have ['s around it, and ,'s in between each item.
belongs_to :userand User modelhas_many :posts, you can instead write@profile.user.postsinstead of that Post.where clause.