# include MD5 gem, should be part of standard ruby install
require 'md5'
# get the email from URL-parameters or what have you and make lowercase
email_address = params[:email].downcase
#create the md5 hash
hash = MD5::md5(email_address)
# compile URL which can be used in <img src=""...
image_src = "http://www.gravatar.com/avatar/#{hash}" />