Action Mailer Interceptors

ActionMailer Interceptors are a great way to test the full stack of your mailing in Rails from the generation from data through to receiving the email in your client. They are similar to ActiveRecord’s before_x-type callbacks, and let you change something about the message being sent right before it’s actually dispatched. The most common purpose I use these for is...

Overriding Action Caches

Recently, I have been working on a web application that is quite media rich, and is expected to run into quite a bit of traffic. I’ve been working on building an API for a front end system, using JSON to handle passing this data back and forth. Obviously with this amount of traffic, and the size of some of the...

Howto: Database Backup and Restore

An inherent part of developing web applications is managing your datastores - typically, a relational database such as MySQL or PostgreSQL. Today, I’m going to quickly cover off how to backup and restore for both of these databases. What you’ll need Either PostgreSQL or MySQL Access to a database (preferably one with data in it) Why this is useful to...

Introducing Blog Broadcaster

I’ve just completed a Blog Broadcaster for this blog. It had a couple of interesting technical things, and I needed to test it properly, so here’s this post! I recently migrated this blog from Tumblr, and while Tumblr was pretty awesome and easy to use, it didn’t have great support for blocks of code and preformatted comment, and, like Radiant...

Select Anything From Everything with Select

I was recently called upon to make a horrible select input for a Ruby on Rails project - essentially, there was this model, let’s call it a Snafu, and one Snafu could share an attachment to any number of models. This select was difficult because I couldn’t just have a selection of record ID’s - I would have to use...

Capistrano rvm-shell: command not found error

I’ve just come across this problem, and I had to share it here - I can’t find anywhere else on the the Internet where the solution is specifically stated - it’s just alluded towards. If you are using RVM’s Capistrano integration, you may come across a CommandNotFoundError to do with rvm-shell not being under / usr/local/rvm/bin (Which is exactly where...

Achievements on Coderwall

Well, it’s taken weeks for Coderwall to finally get it’s crawler to hit my Github Profile, but I’ve finally got more badges. I’ve been moving some old PHP stuff of mine onto Github for people to use, so that’s where I’ve gotten the PHP badge from. As part of my personal campaign to master at least one other language apart...

Arbitrary Ordering in PostgreSQL when Rails + ENUM = No.

I’ve recently had to do a custom sort for a work project that has required a sort on something that is not naturally sortable correctly (For example, alphabetical or numerical sorting). While searching for a completely different solution, I came across this post that outlined a nice technique. Basically, when you have a field in your Rails model with a...

Quick: Clear Gemset

If you’re finding that you have to change something fairly significant in your bundler dependencies, it’s usually a good idea to get rid of what you’ve got loaded in an RVM gemset so that you don’t end up with different versions of gems fighting with each other. To do this, simply run rvm gemset empty - it’ll delete all the...

The Dictionary of New Zealand Sign Language

The Dictionary of New Zealand Sign Language went live on Friday - it’s a project that I have worked on with Daniel, Chris and James R, at 3Months. I attended a launch event at Victoria University on the Friday, and it really was quite a humbling experience - this dictionary has been the effort of a team of people for...