In conjunction with my Physical Computing final, I made a website in Ruby / Sinatra for the Change You Can Believe In device.

Correctly formatting currency on a website is surprisingly difficult. My goal was to record change input from the machine and analyze and display it on the website. A library (Gem in Ruby terms) is available to help make that easier. However, the ITP server does not permit us to add them. So the adventure begins.

The Process

  • Setup Ruby &  Sinatra locally: This let me develop the website on my own computer. Not only was this faster and more efficient than running things on the ITP server, it let me use the gem which made currency display easier. Great. But how to I deploy the site?
  • Figure out Heroku: My host, Dreamhost, does ruby hosting but it isn't that easy to setup. So I went for Heroku instead. Initially, I was following online tutorials that classmates had made for porting ITP apps to Heroku. But I couldn't get the site to run.

Hurray!

That's when I found that Rune had posted a Sinatra Heroku template. This was awesome and after a billion errors, I was able to post the site successfully. It helped that I already had an Amazon S3 account to host static files. But YAML and Heroku aren't friendly. You really have to use Heroku's Postgres database.

Heroku Postgres + Datamapper = :(

Here's where I had the most problems. Datamapper doesn't play well with postgres. I couldn't figure out why my databases weren't working. A resident helped me discover that the issue had to do with an RFID tag int that wasn't an int. In the world of postgres it was a bigint because it was too long to be just an integer.

Datamapper doesn't want to deal with bigints.

Mark helped me figure out that I could store my RFID tag id as a string. Easy enough. However, I  learned that you have to reset & reinitialize the Heroku Postgres database to make it understand that you're changing the datatype.

Here is a look at the website:

[gallery link="file" columns="2" ids="721,725,722,723"]

In the end, everything is working. The code might be a little bit of a mess, but I'm excited that in just 7 weeks I was able to

  • learn the basics of ruby
  • interface my arduino with the web
  • learn about and use the Twitter bootstrap front-end
  • deploy an app on Heroku
  • figure out how to actually use git & push code to Heroku & github from the command line exclusively
  • store and retrieve static assets on Amazon S3

Check out the code here: https://github.com/tomarthur/Change-You-Can-Believe-In-Web

This was quite the adventure and I wouldn't have succeeded without the help of the ITP residents, Mark Kleeb and my awesome professor Rune. Thank you all.

© 2017. Some Rights Reserved.

Ghostium Theme by @oswaldoacauan

Proudly published with Ghost