Paperclip on Windows - undefined method `split' for nil:NilClass

不打扰是莪最后的温柔 提交于 2019-12-24 23:26:34

问题


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'

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?


回答1:


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.

So just put this in your Gemfile until the fix is released:

gem 'paperclip', '3.0.4'


来源:https://stackoverflow.com/questions/11278679/paperclip-on-windows-undefined-method-split-for-nilnilclass

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!