Ruby on Rails problems & solutions - Feb 23, 2011

Handle divide by zero in select in OracleActually, I could do an entire blog entry, or even an conference session on the topic of avoiding the N+1 query problem when displaying data from legacy databases.  Only in my case, it’s more like 7N+1.  But, let’s just get down to today’s specific case.  I needed to display a table of values, and I wanted to be able to sort the table on any of the columns.  Sorting is most efficiently done by the database, no?  But several of the columns were actually derived data, with simple calculations.  You can still sort on such things, IF you create a custom column aka - “SELECT cola/colb as custom_column FROM …”.  Unfortunately, if colb contains any zeros, the query will blow up.  :-p

Ruby on Rails problems & solutions - Jan 24, 2011

Date Formats for Rails 3 It’s surprisingly difficult to find up-to-date, comprehensive info about date formats and time zones for Rails. It’s been a moving target, updated in every release.  This thread pops up a lot:

Ruby on Rails problems & solutions - Jan 21, 2011

Routes and formats For some reason, I got stuck on this.  It’s not explicitly stated anywhere in the new routing documenation/guides, but if you need a format, it’s a parameter for your path: workbook_job_path(job, :format => ‘pdf’)

Im Back


layout: post title: I’m back! categories:

  • business tags: [] status: publish published: true meta: {} —Sorry for the long hiatus in updates. My personal reaction to winter in the frozen north (Calgary, AB, Canada) is to hibernate. But it’s sunny and warmer today, and I feel like updating with some of the long list of Ruby & Rails problems & solutions I’ve been collecting in the mean time.

} else { $('#cookie-notice').show(); } $('#cookie-notice-accept').click(function() { createCookie('cookie-notice-dismissed','true',365); // Change from 1 month to 1 year. $('#cookie-notice').hide(); });