A quick Sublime Text 2 snippet
‘nuf said
Do you ever find yourself doing this?
Here’s a nice little shortcut:
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 :)
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:
I’ve added comments to this blog. So, if you wanted to comment on my posts, now you can!
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.
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:
Here are a couple of bits and pieces that help make this pattern easier:
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:
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: