新手问题 carrierwave 上传头像后生产模式下取不到

dxwts · 2013年12月19日 · 最后由 dxwts 回复于 2013年12月19日 · 2265 次阅读

请问各位,我用 carrierwave 上传头像,在的 development 模式下可以正常使用,切到 production 后上传图片就取不到了,图片有正常上传,这个大概是什么问题引起。

ActionController::RoutingError (No route matches [GET] "/uploads/user/avatar/52b26abf6478775812000000/big_avatar/52b26abf6478775812000000.jpg"): actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:21:in call' actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:incall' railties (4.0.0) lib/rails/rack/logger.rb:38:in call_app' railties (4.0.0) lib/rails/rack/logger.rb:21:inblock in call' activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in block in tagged' activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:intagged' activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in tagged' railties (4.0.0) lib/rails/rack/logger.rb:21:incall' actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in call' rack (1.5.2) lib/rack/methodoverride.rb:21:incall' rack (1.5.2) lib/rack/runtime.rb:17:in call' activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:incall' railties (4.0.0) lib/rails/engine.rb:511:in call' railties (4.0.0) lib/rails/application.rb:97:incall' rack (1.5.2) lib/rack/lock.rb:17:in call' rack (1.5.2) lib/rack/content_length.rb:14:incall' rack (1.5.2) lib/rack/handler/webrick.rb:60:in service' /home/dxw/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/webrick/httpserver.rb:138:inservice' /home/dxw/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/webrick/httpserver.rb:94:in run' /home/dxw/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/webrick/server.rb:295:inblock in start_thread'

1 在服务器后台看看 public 目录下是否能找到这个图片 2 看看你的 nginx 配置信息, 对于 uploads 文件夹的请求,做配置了么

#1 楼 @Victor 哦,好的谢谢我查一下

#1 楼 @Victor 哦,是配置错了,config.serve_static_assets = false 改成 true 就可以了,请问上传头像预览该如何做,需要先用 ajax 保存图片吗?

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册