In case people would like to know how to do it without any gems :
The trick is to get gravatar image with a false default image and then check header response.
It's achieved with the Net::HTTP ruby library.
require 'net/http'
def gravatar?(user)
gravatar_check = "http://gravatar.com/avatar/#{Digest::MD5.hexdigest(user.gravatar_email.downcase)}.png?d=404"
uri = URI.parse(gravatar_check)
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
response.code.to_i != 404 # from d=404 parameter
end
[email protected]
? – Gyronny