Skipping Asset Compilation with Capistrano

13 December 2011

Capistrano has a handy task that runs rake assets:precompile for you when you are deploying your Rails 3.1 application. This gives you an easy way to get the performance boosts of having only one css file and one javascript file to load per request. The price you pay for that benefit is the amount of time it takes to run that rake task when you are deploying. There is a way to get the benefit while reducing that cost, though.

Since capistrano creates a symlink for the assets that is moved across deploys, you really don't need to compile those assets for any deploy where the assets didn't change. Instead, all you need to do is move the symlink. However, the default capistrano for compiling the assets does compile them every time, regardless of whether any assets were changed in the set of commits that you are deploying. The trick, then, is to check the list of files that were changed in the range of commits that are being deployed, and compile the assets only if assets show up in that list. And here is a code snippet that does exactly that:

It only supports git, as that's what I use, so if you use git, just drop that snippet into deploy.rb and enjoy quicker deployments.



Pricing Experiment Follow Up

30 April 2011

Thanks so much to those of you who helped me with my pricing experiment. I feel it was a success, with a lot of great feedback.

Before I launched the survey I had a price in mind, but I wanted to see what the prevailing opinion would be on what the price should be without being influenced by that info. I was pleasantly surprised to find that many of those who responded were willing to pay more than the amount I had in mind, which makes me feel good about the value of the products I offer via Rails Kits.

The OAuth Kit has now been priced and released, but I'll leave the survey open a little longer to let a few more folks get the coupon. :)



A Pricing Experiment

28 April 2011

Today I read about determining pricing by surveying your customers, and it just so happens that I have a new product ready for pricing, so I thought I'd try it out.

Read the rest of this entry »



Auto-spawning Delayed Job Workers

12 April 2011

I've been interested in simplifying lately.... using Chef (solo) to configure boxes, switching to Postgres from MySQL to get decent text search without having to run sphinx, etc. My goal recently has been to cut down the number of moving parts in my deployments to make my life a little easier. So when a client project required background processing, I re-evaluated my stock approach to see if I could simplify a bit.

Read the rest of this entry »



Quick Tip: Sending Google Chart links via email

24 February 2011

Recently I had a client who wanted to deliver reports via email that contained a bunch of charts, and we decided on using Google Charts for the chart rendering. I used the googlecharts gem to create the links to Google. I encountered a problem with the charts not showing up in Gmail, even when the exact same code was working when viewing the reports at the site in the browser.

It turns out that the pipe character used to delimit data, options, etc., in Google Charts URLs didn't play nicely with Gmail. Once they were encoded (converted to %7c), it worked like a champ. So, in my (html) email views, I have this as the src attribute to image tags:

Gchart.line(..., :format => 'url').gsub('|', '%7C')

Problem solved. :)