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
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).
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.
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 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 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 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).
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!