This is my code:
这是我的代码:
def tiny_user_image(user)
8 if user_signed_in?
9
10 gravatar_image_tag(user.email, :gravatar => :identicon, :size => 20)
11
12
13 elsif user_signed_in? && current_user.friends.include?(user)
14
15
16
17 else #user is not signed in
18
19 gravatar_image_tag(user.email, :gravatar => :identicon, :size => 20)
20 end
21 end
22
23 end
'gravatar_image_tag' is this helper: https://github.com/mdeering/gravatar_image_tag
“gravatar_image_tag”就是这个助手:https://github.com/mdeering/gravatar_image_tag
I call tiny_user_image from the partial:
我从部分调用tiny_user_image:
1 = div_for review do
2 = link_to review.title, review_path(review)
3 = tiny_user_image(review.user)
I don't know why I get an error at tiny_user_image passing the object User. When I use debugger in IRB, it looks fine....
我不知道为什么在传递对象用户的tiny_user_image上会出现错误。当我在IRB使用调试器,它看起来好....
thank you!
谢谢你们!
1 个解决方案
#1
1
You are getting this error because you are assigning a symbol as the value for the :gravatar key in the hash you are passing to gravatar_image_tag().
您会得到这个错误,因为您正在将一个符号赋值为您传递给gravatar_image_tag()的散列中的:gravatar键。
In the example on github you can see that it is expecting a hash there
在github上的示例中,您可以看到它期望得到一个散列
gravatar_image_tag('junk', :alt => 'Github Default Gravatar', :gravatar => { :default => 'http://github.com/images/gravatars/gravatar-80.png' })
#1
1
You are getting this error because you are assigning a symbol as the value for the :gravatar key in the hash you are passing to gravatar_image_tag().
您会得到这个错误,因为您正在将一个符号赋值为您传递给gravatar_image_tag()的散列中的:gravatar键。
In the example on github you can see that it is expecting a hash there
在github上的示例中,您可以看到它期望得到一个散列
gravatar_image_tag('junk', :alt => 'Github Default Gravatar', :gravatar => { :default => 'http://github.com/images/gravatars/gravatar-80.png' })