mperham/girl_friday — pull request #43 by coreyti (2011-11-10 09:50:31+00:00)
Title: capture and print exceptions from processor

example:

I am integrating girl_friday support into carrierwave_backgrounder and found that, for a mounted uploader with methods like those in Image (below), the call to #type_name would raise a NameError (as it looks for "Image::Image"). Unfortunately, that error was swallowed, leading to silent failures.

This commit highlights the need to change, in this case, "Image::TYPES" to "::Image::TYPES".

class Image < ActiveRecord::Base
TYPES = [
["One", 1],
["Two", 2]
]

def filename
"image-#{type_name}"
end

def type_name
(Image::TYPES.first { |option| option[1] == type_id })[0]
end
end