Follow Me Icons

 

Follow @KendrickColeman on TwitterConnect on LinkedInWatch My Videos on YouTubeFollow me on FacebookCheck Out My Projects on GitHubStay Up To Date with RSS

Search

BSA 728x90 Center Banner

World Cup Fun with Ruby on Rails

TL;DR - just go here -> http://worldcupstats.cfapps.io/ -> now at http://simpleworldcupstats.herokuapp.com/

 

The World Cup is in full swing and While watching the Brazil v Chile game yesterday I figured I would play around with the unofficial World Cup API. You know the saying "if you don't use it, you lose it"? Well, it seems very true for me when it comes to coding. It seems like I have to constantly re-teach myself things when I don't code for a month or so. On with the fun.

 

William Lam posted on twitter about The World Cup API and Alan "Super PowerCLI Guy" Renouf even made some PowerShell cmdlets in his article PowerShell your world cup.

 

 

Of course, I'm not much for PowerShell so I wanted to create a small rails application. After a few hours of work and doing some twitter bootstrap formatting I had a pretty snazzy little site. It's a simple rails application that only uses the VC part of the MVC concept. No database is necessary. The application will display 3 columns. Top Goal Scorers by individual and team, and who's playing next. When the cup is over, the third column will display the final match results and the World Cup Winner. As you would expect, the page will change as goal counts and matches proceed with the API changes.

 

Since I'm getting on the Cloud Foundry bandwagon, that's where I wanted to deploy it. With a simple cf push --command 'bundle exec rails s -p $PORT' I had my webapp running at http://worldcupstats.cfapps.io/.

 

The updated code is all available on Github at https://github.com/kacole2/Simple-World-Cup-Stats.

 

Here are the only two bits of interesting code if you're wondering how it's all done:

Controller: https://github.com/kacole2/Simple-World-Cup-Stats/blob/master/app/controllers/static_pages_controller.rb

View: https://github.com/kacole2/Simple-World-Cup-Stats/blob/master/app/views/static_pages/home.html.erb

 

 

 I ended up moving the application to Heroku. I was spending $7/month to host this application at PivotalCF and Heroku allows me to do it for free. The new link is now at http://simpleworldcupstats.herokuapp.com/

 

 

 

Related Items