TheRationalDebate Technology Stack

For those of you who know me, you know that I created TheRationalDebate for two main reasons.  The first reason is, obviously, that I really do not like irrational debates (especially on the internet) and I do not like when people site facts without backing up their sources.   The second reason is the technology.  I built the site almost exclusively with technologies that I don’t get to work with in my day job.  The posts so far have been all about the first reason I built the site, so I figured it would be good to do a post about the second.

10,000 Foot View

At a high level, TheRationalDebate is a web application written in Ruby on Rails running on the cloud hosting service Heroku.

I chose Rails mostly because I wanted to sharpen my Ruby and Rails skills.  Plus it’s a lot of fun to code in, and there are tons of open source plugins (what Ruby calls ‘gems’) available to use that make hard things pretty easy.  I’ll talk more about the gems I’m using later.

Heroku revolves around the concept of a ‘dyno’, which is sort of like a server, but it can only process one request at a time.  For tech readers, think of a dyno as more of a web worker thread rather than an actual server.  I chose Heroku for two reasons.  First, it’s really easy to deploy TheRationalDebate to Heroku.  No messing around with servers, databases, etc.  I can simply push my code to Heroku and their software takes care of the rest.  The second reason is price.  I’m running TheRationalDebate at a total monthly cost of $0.  Can’t beat that.  For a small site like mine, I only have one ‘dyno’, and it’s free.  The only downside to this approach is only one user can make a request at a time.  In other words, if you and I point our browsers to the homepage at the nearly the same time, I’m going to have to wait for your request to finish before the server even starts working on mine.  This is also why the Rational button can’t post URLs on TheRationalDebate.  It would create a request that triggers a circular request to the site.  My one lonesome dyno can’t keep up.  This limitation would be a huge flaw for a bigger site, but again, the hosting is free.  If the site ever needs it, I can scale up the dynos to increase performance (for a monthly fee, of course).

User Interface

On the front end, I’m mainly using jQuery and Twitter Bootstrap.  As I mentioned in my last post, I’ve never been confused with a graphic designer, so the CSS is pretty much out of the box.  I am using the Cerulean Bootswatch theme.  I’m still using Bootstrap 2.x; I’ll probably upgrade to 3 at some point when the mood strikes me.

I’m also using a really cool JavaScript library called Isotope to organize Opinion Boards on a user’s profile page.  You can create some pretty neat dynamic layouts.  Here’s an animated gif showing how off how I’m using some of the features:

boards-isotope-layout

If you want to play around with it yourself, go to my Opinion Boards, or create your own boards!

Other Gems of Note

Getting down into the nitty gritty, here are some other Ruby gems I’m using that you might find interesting:

Devise

Devise handles user registration and user sign in/out, manages encrypted passwords in the database, and provides features for password recovery and user verification.  Devise is truly a fantastic gem.  It would have taken me forever to build something anywhere close to this.

Omniauth

Omniauth works with Devise to allow users to sign in to the site via Facebook.  Omniauth is based on the OAuth standard, and supports other authentication providers as well (Google, Twitter, many others).

Paperclip

Paperclip is a simple gem that allows you to attach files to database records.  On TheRataionalDebate, I’m using it to attach an avatar image to a user’s profile.  Another great thing about Paperclip is that it seamlessly integrates with Amazon S3.  I’m using S3 to store uploaded avatar images since Heroku is a read-only file system (which means I can’t store avatars directly within the app).

Turbolinks

Turbolinks makes a site filled with normal anchor tag links work like a JavaScript app by turning those links into Ajax requests.  Without doing anything to my code, Turbolinks improves the site performance while seamlessly degrading to normal links for older browsers.  Turbolinks is also is the main reason I put the “Loading” gif and transparent backdrop between page loads.  If I hadn’t, there would be no user feedback that the page was loading since the normal browser spinner doesn’t spin.  If you don’t see the Loading gif and backdrop between pages, it means your browser is too old to support Turbolinks.  Upgrade your browser!

CanCan

CanCan is a cool little gem that makes user authorization a snap.  I use it to make sure that you can only edit your boards and posts.  If you go to my boards, you won’t be able to edit anything because of how I’m using CanCan.

If You Insist (on geeking out more)

  • HAML and SASS – makes coding HTML and CSS much better.  Less code, more productivity.
  • simple_form – If you’re coding a rails app with the out of the box form_for method, you’re missing out.
  • client_side_validations – I have client-side validations working as much as I can for now, but there are certain places (I’m looking at you, Devise and Bootstrap) that caused problems.  I could probably iron out all the places where I couldn’t figure out how to get client side validations working, but at this point it’s not worth the time.  In case you’re wondering, yes I am using client_side_validations-simple_form and client_side_validations-turbolinks gems as well.

If you made it this far, thanks for reading and let me know if you have any questions about TheRationaDebate’s tech stack!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s