A quick Sublime Text 2 snippet

‘nuf said

Comments

Git tip: git checkout —merge

Do you ever find yourself doing this?

Here’s a nice little shortcut:

Comments

Migration Tests

Earlier today I set out to write a migration with logic (it adds a column and then migrates data), and I thought “wouldn’t it me nice to test this migration”. I’ve seen people write migration tests before, and other blog posts show lots of setup and weirdness. I ended up scraping this migration (and the concept), but I thought I’d post how freaking easy it was to write a simple migration spec:

Normally, I wouldn’t write a spec just for changed columns, but this serves as a nice example and starting point for more complex migrations :)

Comments

Using I18n and Draper to Render Database Attributes

TL;DR;: Check out my additions to ApplicationDecorator in this gist.

When my models have an attribute that matters to the code (like Admin#role or User#status), I like to store the value as a string that makes sense as an identifier. For example, User#status might be ‘active’ or ‘awaiting_approval’. However, when it comes time to render the admin’s role or the users status in the view, we want to show ‘Awaiting approval’ instead of ‘awaiting_approval’. Another example of this sort of thing is the #type attribute for STI.

Ok, this isn’t too hard, we can just use #humanize. But, here’s what happens:

Read More

Comments

I Can Haz Disqus

I’ve added comments to this blog. So, if you wanted to comment on my posts, now you can!

Comments

How to get GetBundles working with RVM

Ever since I set rvm to use ruby 1.9.2 as my default, GetBundles hasn’t been working.

A quick peek at TextMateGetBundles.log revealed that there were syntax errors in Support/getBundles.rb. Here’s what I did to make GetBundles use ruby 1.8.7

This is how I got GetBundles to work with rvm.

Read More

Comments
Do you practice specific skills with repetition and intent? Athletes do drills. Musicians hone difficult passages. What do you do?
Comments

Delete action in Rails 3

At Carnes Media, we’ve been really happy with using a delete action as a confirmation step before calling destroy.

This solves a bunch of problems:

  • No more hacky inline javascripts that create a DELETE form.
  • We render the delete form in a modal instead of a confirm dialog.
  • It’s a completely unobtrusive solution and easy to test with cucumber.

Here are a couple of bits and pieces that help make this pattern easier:

Read More

Comments

Konami jQuery Plugin

Back when I worked at Tatango, Adrian wrote a very concise implementation for the konami code.

So, I figured I would make a nice little jQuery plugin. This is how you would use it:

Read More

Comments

A Couple of Handy Cucumber Transforms

I’m writing some cucumber tests for a billing system, and I figured I’d try cucumber transforms for parsing CreditCard and Money object out of steps. Here’s what I came up with:

Comments
Next »