问题
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