This is so simple it’s almost not even worth posting, but, oh well.
I needed to convert true or false fields from the database to image icons in my views on mutliple pages today, so I wrote this tiny helper and dropped it into my application_helper.rb file.
def true_false(test)
if test == true
icon = 'check.gif'
else
icon = 'x.gif'
end
image_tag(icon)
end
All it does is convert my tinyint fields from MySQL to image icons for a checkmark or an X and I can call it from anywhere since it’s in my application helper.
Cheers