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 have used the asset pipeline heavily since its release in Rails 3.1.0 over two years ago. Only recently did I run in to a handful of gotchas when it came to dealing with stylesheet compilations using Sass. error: cannot access named params by position error: cannot access named params by position I guest wrote a post about my experience using SASS in the asset pipeline at Unbounce.

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

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

Forward: This post is mainly copypasta from an answer I wrote on StackOverflow. It also takes into account the version of Mongoid being used predates the includes method. The includes method being the suggested best practice for the problem now. includes will be mentioned at the bottom of the post. Take me to the current best practice. How to deal with n+1 issues utilizing identity maps: What is the n+1 issue?

Continue reading

Author's picture

Brian Pearce

Software Developer, Endurance Cyclist,
Rubiest, Rustacean, and Gopher

Software Engineer

Barcelona, Spain