为什么我会收到“无法将符号转换为哈希值”的信息在 Rails 3 中使用 helper inside helper 时?
这是我的代码:
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”是这个助手:https://github.com/mdeering/gravatar_image_tag
我从部分调用tiny_user_image:
1 = div_for review do
2 = link_to review.title, review_path(review)
3 = tiny_user_image(review.user)
我不知道为什么在传递对象User时在tiny_user_image处收到错误。当我在 IRB 中使用调试器时,它看起来很好......
谢谢!
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
I call tiny_user_image from the partial:
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....
thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您收到此错误是因为您在传递给 gravatar_image_tag() 的哈希中分配了一个符号作为 :gravatar 键的值。
在 github 上的示例中,您可以看到它需要一个哈希值
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().
In the example on github you can see that it is expecting a hash there