开发者

Why do I get a "can't convert symbol into hash" when using helper inside helper in Rails 3?

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 =&开发者_StackOverflowgt; 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!


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

gravatar_image_tag('junk', :alt => 'Github Default Gravatar', :gravatar => { :default => 'http://github.com/images/gravatars/gravatar-80.png' })
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜