Follow me on Twitter Twitter_16
Subscribe to my RSS feed Rss_16
Posted over 8 years ago

New Features

I just finished with a pretty major update to the site. Most of the new stuff is under the covers. The update was prompted by me wanting to play around with the new features in Rails 3, but I found a lot of other things to improve once I got into the code.


Poker subscriptions

I don’t have to maintain and manage an email list of people who want to know when I’m having a poker game. User’s can now subscribe to the mailing list and when I schedule a new game through the website, an email automatically goes out.

Improved Tournament tracking

You can now see your winnings (or losses) for each tournament and your cumulative winnings in a nice easy to read graph. Thanks to Google Charts and the Mattetti’s supporting google charts gem.

Improved data entry in tournaments

I was able to remove a ton of badly written javascript to handle buy-in’s and re-buys in place of a simple in place ajax gem called best in place. To learn more about this gem check our Ryan Bates screencast.

Under the covers


…is a new web server that I’ve seen several articles about. After I found out that Github uses it I decided to do a bit more research. Unicorn is a different approach to webserver load balancing. It handles requests at the socket layer which enables it to perform as well as other popular web servers but with a lower memory footprint. Unicorn also supports zero downtime deployments.

 desc "Zero-downtime restart of Unicorn"
  task :restart, :except => { :no_release => true } do
    run "kill -s USR2 `cat /tmp/`"

I migrated to Unicorn from Mongrel and found it incredibly easy. I followed Sirupsen’s documentation, except that I used Apache proxy instead of Nginx.

Google Analytics

Not 100% sure what this will buy me yet. It would be interesting to see what searches land people on my page and such, but it was so simple to
set up that I figured I’d check it out.

New Relic

I’ve used New Relic before, but nerver really dived deep into what it provides. I have to say, they have a sweet little setup. It’s simple to add to your Rails application, it provides a simple and intuitive interface, and gets you the information you need to find performance bottlenecks and oppurtunities for improvement. I personally used it to identify places in my code where I was not doing eager loading on model associations. Do I really need to tune these kinds of things for a small site like this? Probably not. But on the other hand, why wouldn’t I?

Other stuff

There’s plenty of blogs out there already about the differences between Rails 2 and Rails 3. I’m not going to go into a ton of details, but I’ll outline a few things I found along the way.


Use relational algebra to build complex SQL queries.

Low Level caching

Rails 3 now has an internal cache that can be used much like memcache or redis. I doubt that it can be used accross multiple webservers in the way that the latter can, but I plan to look for opportunities to take advantage of this.

Haml improvements

I really do enjoy haml. It’s so much less verbose than traditional html. I’m not sure when this was introduced, but I really like the new
feature of Haml that allows you to declare a div without using the %div syntax. When you declare an element by id or class, it assumes a div.

For example:

    #date= print_date
    #address= current_user.address
Spork and Autotest

Sadly, I did not create a suite of rspec and cucumber tests when I wrote version 1 of the site. They would have proved incredibly valuable during a large migration/refactoring like this one. I will stand behind this statement 100%, ‘You can not do large refactorings safely without a good suite of unit/functional tests.’ I’m happy to say I now have a full suite of tests.

Spork essentially caches your rails environment in order to avoid loading the environment everytime you run your test suite. "Autotest" is necissary crutch for TDD. It runs your tests repeatedly until it encouters a failure. Then it runs only the failed tests until the are working.


The entire site, Blog, Poker, and Photos consists of 561 lines of backend code and 359 lines of view layer code. I have 23 unit tests and 19 functional tests. The code is available at github.

comments powered by Disqus