Search code examples
ruby-on-railsrubyruby-on-rails-3ruby-on-rails-3.1ruby-on-rails-3.2

Creating a data visualization site with Rails


I have a very large excel spreadsheet that consists of a user name, a location, a date, and some fields of numbers, for example.

User,location,date,value1,value2,value3

Steve,NYC,2012,9,1,3
Steve,NYC,2011,3,3,2
Steve,CA,2011,1,2,0
Michael,CA,2012,10,3,2
Michael,CA,2011,10,2,0

How would I go about organizing a rails site such that one can view all the values for a certain user?

For example,

/users/steve/all

would display all the values in descending order of date where user=steve.

/users/steve/nyc

would display all the values in descending order of date where user=steve and location=nyc.

I think I would need to create a users model and import all the data from the excel into the database, but I'm lost about how to do that.

The application, in essence, would be a simple data visualizer. Maybe I have to separate the database and create a user has_many :locations and locations :belongs_to user, I'm not sure. I want the data to be viewed in all sorts of ways—maybe I want to display all the users from a certain location, or view all the locations of a certain user, etc...


Solution

  • I suggest setting up your model within your rails application first. Then, you can just write a rake task probably similar to this question or you can build it from scratch. There's also a railscast.