DelayedJob has always been a great “hit the ground running” background task runner for ruby. It is simple to setup, easy to use and can more than carry its own weight in tasks. Don’t know what a backround runner does or why you would use one? I will not delve into why you need one but you can check out a summary here: Background Jobs in Ruby on Rails.

Continue reading

I’ve spent almost the last two weeks dealing with Date and Time Zone related issues within one of the applications I contract on. This is a just a list of notable behaviours I expereinced whilst working with Ruby, Rails, Dates & TimeZones. Note: DST is in effect at the time of writing. Inconsistent Handling of DST In the code below we instantiate an ActiveSupport::TimeZone object. I would love to think that this instance would know everything about that Time Zone.

Continue reading

Last week during my main work contract I had been tasked with doing some would-be trivial content updates to a section of a client application. Content updates would normally involve hopping into a view changing some images or text and re-deploying. This particular section though is a little more complex then that and way more complex then it should be. The Setup This particular section of the application has rotating content.

Continue reading

A quick note on logging SQL queries in DataMapper 1.2 so you can see exactly what’s going on behind the scenes. Seeing the query can be beneficial in debugging when getting unexpected results or trying to increase query performance. DataMapper::Logger.new($stdout, :debug) Enter that at anytime while running in rails c and you should start seeing the output immediatley. Note If you don’t see the output potentially it’s because of DM’s identiity map.

Continue reading

Notes: Working with ruby 1.8.7 but 1.9 solution presented at bottom. While working on my main contract today I needed to create a new array based off mutated values of an existing array. Simple enough I’ll just use Enumerable::map right? Almost immediatley I realized I needed to make a reference to an array via the loops index. I first checked to see if a map_with_index existed similar to Enumerable::each_with_index. It doesn’t.

Continue reading

So while in the #RubyOnRails IRC channel late at night (never a good idea) some silly conversation occured: (someone gists some code) sevenseacat: empty array seems the silly thing to have Tarential: sometimes I like to add empty arrays, you know, just in case I need them later Tarential: so they’re close at hand tagrudev: little kittens die when you define an unused var brianpWins: but if you do want to leave empty arrays around.

Continue reading

Author's picture

Brian Pearce

Software Engineer, Endurance Cyclist,
Rubiest, and Rustacean

Software Engineer

Barcelona, Spain