I have the following code in my view:
<%= gravatar_for @user %>
and the following code in my helper:
module UsersHelper
def gravatar_for(user)
gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
gravatar_url = "http://gravatar.com/avatar#{gravatar_id}.png"
image_tag(gravatar_url, alt: user.first_name.to_s + user.last_name.to_s, class: gravatar)
end
end
However I’m getting an error: undefined local variable or methodgravatar’ for #<#:0x00000100a1cbf0>`
What could be causing this?
You’re using a reference,
gravatar, in the call toimage_tag.If you mean to apply a style, use a string,
"gravatar". Otherwise you need to make sure the method or valuegravatarexists/is initialized, and available.