我正在尝试使用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
答案 0 :(得分:2)
您的插件可能与您的rails版本不兼容。使用插件时,Gravatar图像并不难。以下是Ryan Bates对Gravatars
的解决方案application_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) %>