Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何修复这个Ruby on Rails和Gravatar gem bug?_Ruby On Rails_Gem_Gravatar - Fatal编程技术网

Ruby on rails 如何修复这个Ruby on Rails和Gravatar gem bug?

Ruby on rails 如何修复这个Ruby on Rails和Gravatar gem bug?,ruby-on-rails,gem,gravatar,Ruby On Rails,Gem,Gravatar,我试图使用gravatar_image_tag RoR插件,当我启动rails控制台或rails服务器时,它给了我这个错误。我该怎么做才能修好它 /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.beta1/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb:66: uninitialized constant ActionView::Helpers::AssetTagHelper::Asset

我试图使用gravatar_image_tag RoR插件,当我启动rails控制台或rails服务器时,它给了我这个错误。我该怎么做才能修好它

/Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.beta1/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb:66: uninitialized constant ActionView::Helpers::AssetTagHelper::AssetPaths::Mutex (NameError)
    from /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.beta1/lib/action_view/helpers/asset_tag_helper.rb:3:in `require'
    from /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.beta1/lib/action_view/helpers/asset_tag_helper.rb:3
    from /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.beta1/lib/action_view/helpers.rb:39
    from /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.beta1/lib/action_view/base.rb:134
    from /Library/Ruby/Gems/1.8/gems/gravatar_image_tag-1.0.0/lib/gravatar_image_tag.rb:97
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.13/lib/bundler/runtime.rb:68:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.13/lib/bundler/runtime.rb:68:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.13/lib/bundler/runtime.rb:66:in `each'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.13/lib/bundler/runtime.rb:66:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.13/lib/bundler/runtime.rb:55:in `each'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.13/lib/bundler/runtime.rb:55:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.13/lib/bundler.rb:120:in `require'
    from /Users/pickhardt/projects/sample_app/config/application.rb:7
    from /Library/Ruby/Gems/1.8/gems/railties-3.1.0.beta1/lib/rails/commands.rb:51:in `require'
    from /Library/Ruby/Gems/1.8/gems/railties-3.1.0.beta1/lib/rails/commands.rb:51
    from /Library/Ruby/Gems/1.8/gems/railties-3.1.0.beta1/lib/rails/commands.rb:48:in `tap'
    from /Library/Ruby/Gems/1.8/gems/railties-3.1.0.beta1/lib/rails/commands.rb:48
    from script/rails:6:in `require'
    from script/rails:6

您的插件可能与您的rails版本不兼容。没有插件,Gravatar图像并不难处理。以下是Ryan Bates为您提供的解决方案

应用程序\u helper.rb

def avatar_url(user)
  if user.avatar_url.present?
    user.avatar_url
  else
    default_url = "#{root_url}images/guest.png"
    gravatar_id = Digest::MD5.hexdigest(user.email.downcase)
    "http://gravatar.com/avatar/#{gravatar_id}.png?s=48&d=#{CGI.escape(default_url)}"
  end
end
users/index.html.erb

<%= image_tag avatar_url(user) %>