1
目前我已经的Gravatar在我的网站这种方式来实现:Rails和的Gravatar:添加自定义的默认图像
在application_helper.rb:
def avatar_url(user)
default_url = "#{root_url}images/guest.png"
gravatar_id = Digest::MD5.hexdigest(user.email.downcase)
"http://gravatar.com/avatar/#{gravatar_id}.png?s=200{CGI.escape(default_url)}"
end
在我_nav.html.erb查看:
<%= image_tag avatar_url(current_user), :class => 'gravatar' %>
什么是最好的方式来定制默认gravatar URL显示如果au ser没有关联到他们的电子邮件地址?
会在哪里是IMAGE_URL生活?应用程序助手?在安装gem后,在我的视图中尝试使用此方法时,我收到了未定义的方法'gravatar_image_tag'。 – beaconhill
是否添加了初始化程序config/gravatar_image_tag.rb,如此处所示.. https://github.com/mdeering/gravatar_image_tag#global-configuration-points? – blotto
我们走了。谢谢! – beaconhill