Windows上的回形针-nil:NilClass的未定义方法"split" [英] Paperclip on Windows - undefined method `split' for nil:NilClass
问题描述
当我尝试保存上传的文件时,我得到了nil:NilClass的未定义方法'split'
I am getting undefined method `split' for nil:NilClass when I am trying to save uploaded file
@user.avatar=params[:user][:avatar]
这是服务器日志中的错误:
Here is the error from server log:
[32mCommand[0m :: identify -format %wx%h "C:/progs/web/ror_site_1/tmp/Rus220120701-4976-1sky1nn.jpg[0]"
[32mCommand[0m :: identify -format %m "C:/progs/web/ror_site_1/tmp/Rus220120701-4976-1sky1nn.jpg[0]"
[32mCommand[0m :: identify -format %m "C:/progs/web/ror_site_1/tmp/Rus220120701-4976-1sky1nn.jpg[0]"
[32mCommand[0m :: convert "C:/progs/web/ror_site_1/tmp/Rus220120701-4976-1sky1nn.jpg[0]" -resize "300x300>" "C:/progs/web/ror_site_1/tmp/Rus220120701-4976-1sky1nn20120701-4976-a9j1sh"
[32mCommand[0m :: file -b --mime "C:/progs/web/ror_site_1/tmp/Rus220120701-4976-1sky1nn20120701-4976-a9j1sh20120701-4976-tm6qoj"
[1m[36m (0.0ms)[0m [1mROLLBACK[0m
Completed 500 Internal Server Error in 406ms
NoMethodError (undefined method `split' for nil:NilClass):
app/controllers/users_controller.rb:94:in `block in update'
app/controllers/users_controller.rb:93:in `update'
我猜想问题在于文件名太长(C:/progs/web/ror_site_1/tmp/Rus220120701-4976-1sky1nn20120701-4976-a9j1sh20120701-4976-tm6qoj)并且无法在Windows中读取.如果是这样,如何更改文件名生成规则?
I guess the problem in that the filename is too long (C:/progs/web/ror_site_1/tmp/Rus220120701-4976-1sky1nn20120701-4976-a9j1sh20120701-4976-tm6qoj) and cannot be read in Windows. If that is true, how to change filename generation rules?
如果不是,那是问题的原因吗?
If not, that is the reason for the issue?
推荐答案
这是几个最新版本的回形针存在的问题(解释).我也遇到了这个问题,直到我将回形针设置回3.0.4版本后,它才再次起作用.
This is a problem with the few latest releases of paperclip (explained here).I also had this problem, and it wasn't until I set paperclip back to version 3.0.4 that it worked again.
因此,只需将其放入您的Gemfile中,直到修复程序发布为止:
So just put this in your Gemfile until the fix is released:
gem 'paperclip', '3.0.4'
这篇关于Windows上的回形针-nil:NilClass的未定义方法"split"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!