PriceOfWeed.com is a website where users can submit how much they pay for marijuana. If you click a state, you can see how many users have submitted their transactions, and the average prices paid.
Here’s how I assume it works:
- User submits how much they paid using the form at the top of the site.
- That price is inserted into the site owners’ Fusion Table.
- The Fusion Table map now reflects the updated info.
What I am trying to understand is how this process could work in Ruby — specifically, step 2. I’d like to use Fusion Tables and Ruby to make a cool map with dynamically updated data, but I have yet to find simple instructions/examples on how to do it.
Does anyone know how I can use Ruby to automatically add rows to my own Fusion Table?
I have used the fusion_tables gem to use Google Fusion Tables for generating US State-wise & County-wise mapped information.
It is pretty simple to work with. The README.md file explains the steps involved in working with the fusion tables.
Here’s how the overall structure works:
1. Create the base fusion table to store the required data.
2. Merge it with the publicly available fusion table containing the geographic info (State-wise/county-wise, etc.), and create a map view.
3. With the fusion_tables gem based ruby code, insert records into the base fusion table. The map gets updated with the new info.
The code to insert records would be as follows: