Friday 27 September 2013

What's the most efficient way to serve external data (tsv or json) to Ruby on Rails?

What's the most efficient way to serve external data (tsv or json) to Ruby
on Rails?

d3 allows to load external data into javascript to generate SVG data
visualization. But working with Rails (4.0) is tricky because I can't get
an external data file, like a .tsv or a .json served so that the
javascript can pull the data. It's not practical to add it manually to the
js file, as an arrow or something, because of data quantity. But is not
easy to find a solution to serve the static file either. I was trying to
make the browser read the .tsv and then set the javascript to read from
the URL, but no luck.
I have my javascripts in the right place (it's served in the browser) :
app/assets/javascripts/data.js and I'm trying to get it with :
d3.tsv("data.tsv", function(error, data) {...
thanks!

No comments:

Post a Comment